Search code examples
meteorreactive-programmingmeteor-blaze

Meteor mongo what is fetch()?


I recently started learning Meteor, so i learned how to work with Mongo via Meteor but there is something i don't understand, in the web I often see examples like: SomeCollection.find().fetch() , I cannot see what is fetch() is good for?

In the docs, they say:

When called from a reactive computation, fetch registers dependencies on the matching documents

Does that mean that when the data in SomeCollection changes they will be changed in the view?

Isn't the cursor returned by find() is reactive by default (the changes on the data on the cursor will automatically be visible in the view)?

Can anyone clear this ambiguity for me ?


Solution

  • I see the documentation says:

    Return all matching documents as an Array.

    Collection.find() returns a cursor containing the matching documents to that collection, and Collection.find().fetch() returns an array(containing those documents) to that cursor.