I would like to get specific attributes of certain user:
db.future_tasks.find({userid:seb123}).number // Expected to get value of TEST1d82c6
db.future_tasks.find({userid:seb123}).count // Expecte to get value of 1
why are they all not returning values as expected? What is the best practice in trying to get attributes? Thanks
I’m not quite sure what you’re asking, but you can work with the returned cursor pretty much any way you want to. For example, if you want an array of task numbers (only) for all tasks that have a userid of seb123, you could do something like the following in your mongo console:
But why is it thinking that it is now a method which cannot be found?
TypeError: Object [object Object] has no methods ‘jobs’
BUT it is not a method, just one of the collection key name I changed from count to jobs, why it is thinking it is a method?
Or is it just so happens that ‘count’ is a method with mongodB which coincides with my name ‘count’ in collection? So that it is calling the internal method ‘count’ instead of my ‘count’ attribute? So if I changed to ‘jobs’ then how to repeat that call db.future_tasks.findOne({userid:‘seb123’}).jobs because I thought this is calling the jobs object and not the method which now it cannot find?
The mongo shell behaves different from Meteor. Try connecting to your app you started on your system with meteor run by going into the directory of your project in a second window and type meteor shell. That will give you an interactive shell into the server side of your project.
this is getting the attribute .number in my collection so surely when I changed count to ‘jobs’ I should also find it but it is complaining that jobs is a method that cannot be found???