Thursday, 16 June 2016

how to use regex with mongoose



{ name: new RegExp("peter")}

Above regex will automatically change your seach to "/peter/" which like SQL  like %peter%

If you want to do case-insensitive query, you can do:

{ name: new RegExp("peter", 'i')}






No comments:

Post a comment