regex

12 views
Skip to first unread message

Rick

unread,
Aug 12, 2010, 11:53:18 AM8/12/10
to node-mongodb-native
Hi guys

When I'm querying my mongodb using regular expressions - literal
constructors work fine i.e.

find({n:/rick/i})

returns anything with n: that contains "rick"

However, since I'm writing a search query I do not know the string I
want to pass until runtime - so I tried using the following:

var searchString = "rick"
find({n:new RegExp(searchString, "i")})

I dont get any results - but from the mongodb shell it works!

Any ideas?

Christian Kvalheim

unread,
Aug 12, 2010, 12:10:14 PM8/12/10
to node-mong...@googlegroups.com
Are you running higher than 1.4 ?

There's a change in regexp in 1.5 -> that breaks it with the current driver. I have not had any time to look at how to resolve it.
If you can figure it out or someone else has time to look at it please help out.

Cheers

Christian

rick....@gmail.com

unread,
Aug 12, 2010, 12:19:03 PM8/12/10
to node-mong...@googlegroups.com
1.4 actually!

Christian Kvalheim

unread,
Aug 12, 2010, 12:26:58 PM8/12/10
to node-mong...@googlegroups.com
so it's probably a parser error when doing

toString on the regexp to transform it to bson

Please see if you can provide a failing test in integration_tests.js and give me a push on github

Cheers

rick....@gmail.com

unread,
Aug 12, 2010, 12:38:01 PM8/12/10
to node-mong...@googlegroups.com
will do. Cheers for the pointer :)
Reply all
Reply to author
Forward
0 new messages