Andrew5567095
Posts: 0
Joined: Wed Feb 20, 2013 5:42 am

how to write a wildcard search in where clause

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'?

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

how to write a wildcard search in where clause

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

Andrew5567095
Posts: 0
Joined: Wed Feb 20, 2013 5:42 am

how to write a wildcard search in where clause

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

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

how to write a wildcard search in where clause

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.

B510
Posts: 0
Joined: Wed Jun 04, 2014 2:17 pm

how to write a wildcard search in where clause

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

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

how to write a wildcard search in where clause

Please try this:pre

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

Return to “Issues”