Groups
Sign in
Groups
Derby
Conversations
About
Send feedback
Help
Regular expressions in model.query
70 views
Skip to first unread message
Hugh Lomas
unread,
Aug 9, 2013, 11:57:01 AM
8/9/13
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to der...@googlegroups.com
Attempting the equivalent of
var itemsQuery = model.query('items', { name: /a/i });
returns no results. Running db.items.find({ name: /a/i }) in mongo CLI returns results as expected.
Is this unsupported?
Dennis Torres
unread,
Aug 9, 2013, 12:41:13 PM
8/9/13
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to der...@googlegroups.com
I've found that embedding the regex directly like that doesn't work but rewriting it like this does:
model.query('items', {name: {$regex: 'a', $options: 'i'}});
Hugh Lomas
unread,
Aug 9, 2013, 12:49:05 PM
8/9/13
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to der...@googlegroups.com
Wonderful! I had tried
model.query( 'items', { name: { $regex: /a/i } } );
without success but your syntax seems to be working great. Thank you!
Alexey Balekhov
unread,
Dec 2, 2015, 3:39:44 AM
12/2/15
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Derby
Support for RegEx objects is necessary too. Because there is no way to use strings with $not operator:
https://docs.mongodb.org/manual/reference/operator/query/not/#op._S_not
. Is there any other hack for this?
пятница, 9 августа 2013 г., 20:49:05 UTC+4 пользователь Hugh Lomas написал:
Reply all
Reply to author
Forward
0 new messages