techfort / LokiJS

javascript embeddable / in-memory database
http:/techfort.github.io/LokiJS
MIT License
6.73k stars 482 forks source link

question: proper way to read whole collection's data #871

Closed work67 closed 2 years ago

work67 commented 3 years ago

Hi, which is better:

  1. var array_of_all_items = collection.data

or

  1. var array_of_all_items = collection.find()

?

I need to know the proper way to load ALL items from a collection into a variable. The lokijs docs explain how to query a collection, but what is the best query for "getAll" ?

robertdavid010 commented 3 years ago

Hi, which is better:

1. var array_of_all_items = collection.data

or

1. var array_of_all_items = collection.find()

?

I need to know the proper way to load ALL items from a collection into a variable. The lokijs docs explain how to query a collection, but what is the best query for "getAll" ?

If the data is equivalent, then wouldn't the first case to directly access the data be more computationally efficient then calling a method to get the same data?

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.