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

find with string functions #10

Closed
andineck opened this issue Mar 17, 2015 · 5 comments
Closed

find with string functions #10

andineck opened this issue Mar 17, 2015 · 5 comments

Comments

@andineck
Copy link

I started using mingo. It's been really great so far.
What I am missing (or don't understand to do) is, finding documents with string functions like: contains, startsWith, endsWith.

How do I do this more elegant (contains):

var result = Query.find(npm.rows, {$where: 'this.id.indexOf("express") !== -1'}).all();
// or
var result = Query.find(npm.rows, {id: /mocha/g}).all();
@kofrasa
Copy link
Owner

kofrasa commented Mar 17, 2015

I believe the regular expression variant is clearer and more elegant.

@andineck
Copy link
Author

is there also an elegant way without RegExp?
I have to serialize the query object and reqular expressions are cumbersome for this use case.
Is there a way to mixin functions like: contains, startsWith, endsWith.

@kofrasa
Copy link
Owner

kofrasa commented Mar 17, 2015

I decided to exclude special operators not found in the original MongoDB implementation. However, there is room for a feature that would allow registering custom operators. I did not think it would be necessary. With such a feature, that would mean loading up your custom operators into Mingo before running your serialized query.

@andineck
Copy link
Author

makes sense, thx for the explanation.

@kofrasa
Copy link
Owner

kofrasa commented Dec 19, 2016

Although this may long be overdue, I would like to say that Custom Operators are available now.

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