Regex: Error: Can't use $options with String
See original GitHub issueAs defined in the MongoDB documentation, the following syntax :
find(name: { $regex : 'abc', $options: 'i' } )
is correct.
However, I’ve got the error Can’t use $options with String
The same query works when I use directly the mongo shell. I’m using mongoose 2.3.10 and mongo 2.0
Issue Analytics
- State:
- Created 12 years ago
- Reactions:2
- Comments:16
Top Results From Across the Web
Mongoose Error: Can't use $or with String - Stack Overflow
When using $or with "expressions" that are equality checks for the value of the same field, use the $in operator instead of the...
Read more >Can't use $regex with String - Google Groups
); I run this against mongoose 2.1.0 (updated a few seconds ago via npm), and it fails with the following error message: Error:...
Read more >Using $regex inside an $or: error
However I'm getting this error from mongoosejs: ERR: [Error: Can't use $options with Array.] While the same works in the mongodb command line...
Read more >$regex — MongoDB Manual
Provides regular expression capabilities for pattern matching strings in queries. MongoDB uses Perl compatible regular expressions (i.e. "PCRE" ) version 8.42 ...
Read more >perlre - Perl regular expressions - Perldoc Browser
A single /x tells the regular expression parser to ignore most whitespace that is neither backslashed nor within a bracketed character class. You...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m having an almost identical issue, except that I’m using a variable:
and getting the same error. I had to solve it with:
just pass a RegExp directly: