techfort / LokiJS

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

Mulitple ranges / between possible? #866

Closed trompx closed 2 years ago

trompx commented 3 years ago

Hello,

I have a hard time figuring out if it is possible to find documents with multiple ranges. I have filters that documents must match (-> AND) and filters which are array of ranges (documents must match at least one -> OR). Example: price either between 50-100 or 250-500 or 1000-2000.

Is it feasible with lokijs? I could create multiple queries and merge them but I have multiple filters that are array of ranges so if I have 3 filters with 5 ranges, I would need to make 5^3 queries...

trompx commented 3 years ago

Don't know if this is the optimal solution but for those looking for the same, I ended up chaining find() with a custom where() query.

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.