Page 1 of 1

how to write a wildcard search in where clause

Posted: Wed Feb 20, 2013 5:47 am
by Andrew5567095

How doing a db query how do you write a wildcard search i.e return all Cities beginning with 'SA' or all cities that contain 'ck'?


how to write a wildcard search in where clause

Posted: Wed Feb 20, 2013 8:42 am
by Kateryna Grynko

Hi Andrew,

You can use regular expressions (Regexp).

For example, to search cities beginning with SA* you should create following mask:code{City:{$regex: "SA"}}/code


how to write a wildcard search in where clause

Posted: Wed Mar 20, 2013 6:17 am
by Andrew5567095

A follow up question on writing where clauses with multiple queries

I am writing a multiple where clause where one input is a local storage variable (VariableA) and the other is an input field (InputA.Text), can you please help with providing the proper syntax

{"Name": {"$regex": InputA.Text},"id._id":VariableA}

A secondary question, for a Database Service if I am using the Query service can I add new parameters to the query service i,e. Name and id._id


how to write a wildcard search in where clause

Posted: Wed Mar 20, 2013 7:42 am
by Kateryna Grynko

Hi,

For creating the request to database you would need to map localStorage variable to Request parameter "where"
Image

Then click "Add JS" and paste the following code:

codevar inputValue = Tiggzi("InputA").val();
var whereClause = {"Name": {"$regex": inputValue},
"id._id": value};

return JSON.stringify(whereClause);/code

As for your secondary question, for a Database Service if I am using the Query service can I add new parameters to the query service i,e. Name and id._id

Query Service accepts "where" parameter only. If you need to create request by field Name or id._id then you would need to generate request as I wrote above.


how to write a wildcard search in where clause

Posted: Sun Jun 22, 2014 12:31 pm
by B510

I think I am facing with limitation of the query.. :(

  1. there is Case sensitive problem .. (Dog is not same with dog)...

    {"locmaps": {"$regex": 'Dog'} };

    is there any switch or option to turn off case-sensitive?

    please help

    thanks


how to write a wildcard search in where clause

Posted: Sun Jun 22, 2014 12:41 pm
by Alena Prykhodko

Please try this:pre

{"locmaps": {"$regex": "(?i)Dog"}}/pre