Łukasz Gozda Gandecki
Łukasz Gozda Gandecki

Reputation: 364

minimongo query only specific fields

I read in http://projectricochet.com/blog/meteor-js-performance that it is a good practice to specify fields you want to query from the db. It made sense in sense of speed, and in terms of reactivity.

I have a modal where I only display my course name. I don't want this modal to be rerendered everytime someone changes something about the course. So I tried to do:

Courses.findOne({}, {fields: {name: 1, admins: 0}})

But it gives me the whole object anyway (having only name: 1 or admins: 0 didn't change anything):

Object {_id: "multiplicationCourse", name: "Multiplication table", admins: Array[2], upVotes: Array[0], downVotes: Array[0]…}

Am I doing something wrong? Or is it because this course was downloaded somewhere in the code before and this is looked up from the cache not actual the db?

Or do I always get all the data that I publish on the server-side, no matter what I put in "fields" on the client side?

Thanks!

Upvotes: 2

Views: 1296

Answers (1)

gabrielhpugliese
gabrielhpugliese

Reputation: 2588

It's not possible to return specific fields in client: http://docs.meteor.com/api/collections.html#fieldspecifiers

Upvotes: 3

Related Questions