Closed GobsRuiz closed 2 years ago
What do you get if you try: var items = clientes.data
explanation: "data" can be two things:
a property of the collection - gets you all collection data as an array of objects. Careful because it is passed by reference, so for example if you modify "items" above like: delete items[0] the 1st document from the collection clientes will be deleted.
"data" can also mean the data() method (function) of the resultSet object - it does a similar job as "data" property above but is used with chain()
I suppose you are not initialising the "db" properly so whatever you do will return null/undefined. That's why I asked about what clientes.data returns.
Cheers.
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.
I'm trying to return a list / array of database data.
I found some examples, a little confusing, I tried here but it didn't work. My code right now looks like this
var clientes = db.getCollection('clientes'); var resultado = clientes.chain().simplesort("mame").data(); console.log(resultado)
In the console it returns this: "index.js:9 Uncaught TypeError: Cannot read property 'chain' of null"
i'm using loki js