Case Insensitive Database Query
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?
Catch up wih the Appery.io community on our forum. Here you'll find information on the lastest questions and issues Appery.io developers are discussing.
https://forum.appery.io/
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?
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.
Thank you Yurii!