techfort / LokiJS

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

[Feature Request] Dot notation support for array index position #864

Closed adueck closed 2 years ago

adueck commented 3 years ago

With mongodb you are able to use dot notation to access not only keys in an object but also positions in an array.

Here is an example of querying for an element by array index position.

It would be great if the dot notation used in lokijs supported this as well, so we could do something like this:

var items = db.addCollection('items');
items.insert({ foo: ["abc", "def"] });
var result = items.findOne({ "foo.1": "def" });

or perhaps (departing from the mongodb syntax a little to differentiate between index x and a key named "x"

var result = items.findOne({ "foo[1]": "def" });
stale[bot] commented 3 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.