techfort / LokiJS

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

can't query for nested object equality #889

Closed woojoo666 closed 2 years ago

woojoo666 commented 3 years ago

with MongoDB I can create a document like

{ name: { first: 'Bob' } }

and then query it using find({ name: { $eq: { first: 'Bob' } } })

However this doesn't seem to work in LokiJS. I tried this piece of code in the official sandbox:

var db = new loki('sandbox.db');
var items = db.addCollection('items');
items.insert({ name: { first: 'Bob' } });
logObject(items.find({ name: { $eq: { first: 'Bob' } } }));

And the query returned no results. I also tried items.find({ name: { $eq: { first: { $eq: 'Bob' } } } }), but that didn't work either.

You can also see it running live at codesandbox

Does LokiJS support such queries? And if not, what's the alternative?

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.