Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search in Arrays #91

Closed
DominicBoettger opened this issue Mar 9, 2015 · 5 comments
Closed

Search in Arrays #91

DominicBoettger opened this issue Mar 9, 2015 · 5 comments

Comments

@DominicBoettger
Copy link

I have a array in my documents:

///
{
title: 'test',
topics: [{id: 1, title: 'topic1'}, {id:3, title: ' topic3'}]
}
///

Is it possible to search for documents where topics.id = 3.
In mongodb i can do this with 'topics.id': 3. Is it possible to search in arrays like this with loki?

Thanks
Best regards
Dominic

@obeliskos
Copy link
Collaborator

(removed)

@obeliskos
Copy link
Collaborator

Sorry... I should have read more carefully.

Currently 'no', our dot notation currently does not work on arrays. This seems to be something we could add without too much effort so I will look into adding it over the next few days or so.

Until then you could use 'where' clauses which use javascript filter functions to do this filtering.

@obeliskos
Copy link
Collaborator

I did initial checkin of changes which support your example. In doing so I noticed dot notation may not be detecting properly when you include an operator. I'll work on that next but in meantime, form your query with implicit equals operator like :

coll.find({'topics.id', 3});

If you prefer to wait I will probably do further testing and fix operator detection over the next few days.

@DominicBoettger
Copy link
Author

Hi,

thanks for your work! I will not be able to use it for my current project, but it will be helpful in the future.

Best regards
Dominic

@obeliskos
Copy link
Collaborator

No problem. Seems explicit operators ('$eq', '$gt', '$lt'...) work fine.

Added test cases which validate this subarray searching, so closing issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants