What's the right way to check if collection.find success in Meteor? -


said 'a cursor returns returns', and 'fetch' can be used to return all mailing documents I did not, but I did not find the full context of this cursor object.

I want to check this cursor object to successfully find some results or nothing.

The following is what I am doing:

  if (tag.find ({name: tag ["tag"]}). Fetch (). Length === 0) {// Not Found, Add Default Document}  

To ensure that this is the best (practiced) method?

idiom usage:

  if (! TagFindOn (. ..)) {// nothing found, add default document}  

It is more efficient fetch () because it only databases for a document Asks.

You can also use it, but be careful.


Comments