Page 1 of 1

Case Insensitive Database Query

Posted: Sun Jul 13, 2014 9:35 pm
by Cameron

Hi. I am trying to make a case insensitive database query. My current query is:

return '{"Product":"'+value+'"}';

I tried: return '{"Product":{"$regex":"value", "$options":"i"}}

with no success. Any help?


Case Insensitive Database Query

Posted: Sun Jul 13, 2014 10:20 pm
by Yurii Orishchuk

Hi Cameron,

Your second "where" value is ok:

pre

{"Product":{"$regex":value, "$options":"i"}}

/pre

But there could be error with code wrapping.

Please use this code:

pre

var whereObject = {"Product":{"$regex":value, "$options":"i"}};

return JSON.stringify(whereObject);

/pre

Regards.


Case Insensitive Database Query

Posted: Sun Jul 13, 2014 10:27 pm
by Cameron

Thank you Yurii!