What is the difference between Lists.find() and Lists.find().fetch()?


#1

The difference is that Lists.find() is reactive
and
Lists.find().fetch() is not reactive ?

Probably a silly question for someone with meteor experience.


#2

The first one returns a cursor while the second one returns an array. Nothing to do with reactivity.


#3

Would you mind explaining the difference, and use cases? :slight_smile:


#4

Check those links for cursor definition:
https://www.quora.com/What-is-cursor-in-MongoDB-and-its-use
https://docs.mongodb.com/v3.0/core/cursors/


#5

so both are reactive ?
when you return a cursor from a template helper,
it behaves like an array.


#6

Yes both are reactive.


#7

Yes, essentially it does act like an array, even though it’s not. Blaze is just smart enough to recognize a cursor and iterate over the elements (documents) it contains, if you’re using an {{#each lists}} ... {{/each}} construct.