简体   繁体   中英

Not able to understand meteor specific syntax

I was reading about Meteor publishing and subscription, where i came across a small code snippet. Although, i understood the concept of the article but could not understand the code syntax of snippet. Please help me?

Meteor.publish('lists.public', function() {
  return Lists.find({
    userId: {$exists: false}
  }, {
    fields: Lists.publicFields
  });
});

Here is your code annotated with explanations. Does this help?

// publish the result of this function to the client under the name 'lists.public'
Meteor.publish('lists.public', function() {  

  // Find in the Lists collection..
  return Lists.find({
    // ..all documents there the field userId does *not* exist.
    userId: {$exists: false}
  }, {
    // From the found records, only return the fields listed in Lists.publicFields.
    fields: Lists.publicFields
  });
});

You may also want to console.log(Lists.publicFields) somewhere in case you are not sure what's in there. This is not meteor specific and I cannot tell what is set in there. Might be done by a package you are using.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM