Page 1 of 1

Database query using a "like" operator

Posted: Sat Apr 25, 2015 1:36 pm
by Bob Fludder

Hi. I've not used the database feature before but slowly getting the idea but the select statement has me stumped (could probable do it in sql but not this). What I want to do is return all records where a database field is like a value in a search field and be case insensitive. So if only 1 character in the search entered just get those records that match that character in position 1 (ignoring case). Likewise if 2 entered then matches the first 2 characters etc etc. Sort of like autocomplete I guess. How would I code that ?


Database query using a "like" operator

Posted: Sat Apr 25, 2015 1:45 pm
by Bob Fludder

Oh and I'm guessing it will have something to do with a regex but I have no idea how they work. In fact I can't even spell it....


Database query using a "like" operator

Posted: Mon Apr 27, 2015 6:32 am
by Serhii Kulibaba

Hello Bob,

Use this where parameter:

{"columnName":{"$regex":".test.","$options":"i"}}

here:

columnName - name of column for search
test - search query
i - option "ignore case"


Database query using a "like" operator

Posted: Mon Apr 27, 2015 7:40 am
by Bob Fludder

Thanks Sergiy. I'll give it a try.