Meteor – collection.find() always returns all fields

your syntax is off a bit, it should be

CollectionName.find({}, {fields: {'onlyThisField':1}});

or

CollectionName.find({}, {fields: {'everythingButThisField':0}});

your template does indeed control what data is displayed, but there are still many scenarios where field limiting makes sense – privacy of data or efficiency (some fields of all records, all fields of the ‘current’ record) are two common ones

you didnt mention it, but this usually is within a publish function – see http://docs.meteor.com/#meteor_publish – the fields modifier is also available on the client, but there it does not limit data sent down to client, just to the template – server side field reduction/selection has different benefits

double check that you’ve removed the autopublish package too, however you should see a warning if you have that active and write your own publish functions, which is where you would most commonly use fields

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)