Joseph Yeung
Posts: 0
Joined: Tue Aug 14, 2012 7:48 am

Multiple values for "where" in one database query

Hello, Tiggzi team.

I'm aware that when querying (request mapping) a tiggzi database, I can use javascript at the "where" parameter, e.g. {“Maker”:”Samsung”}.

but how about I have multiple values for querying, e.g. "where": maker is Samsung, Nokia, or Sony.

Also, in another case how about would like to query "where": maker is Samsung and model is Galaxy Note III?

Any help is appreciated!

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

Multiple values for "where" in one database query

Hello Joseph,

http://docs.tiggzi.com/documentation/...

This might look like:
code{"Maker":{"$in": ["Samsung","Nokia"]}, "model":"Galaxy Note III"}/code
Conditions in several columns unit using logical AND. It means that in example above "Maker" is:
code{"$in": ["Samsung","Nokia"]} AND "model":"Galaxy Note III"/code

Joseph Yeung
Posts: 0
Joined: Tue Aug 14, 2012 7:48 am

Multiple values for "where" in one database query

Thanks for you prompt reply. I would check it out.

Joseph Yeung
Posts: 0
Joined: Tue Aug 14, 2012 7:48 am

Multiple values for "where" in one database query

Hello!

Could you also tell how I put the expression in a custom ajax request? The setting item should be called "data" or whatever?

My guess:
precode
$.ajax({
dataType: 'json',
data: {"Maker":{"$in": ["Samsung","Nokia"]}, "model":"Galaxy Note III"},
url: 'https://api.tiggzi.com/rest/xxxxxx',
beforeSend: function (xhr) {
xhr.setRequestHeader('X-Tiggzi-Database-Id', 'xxxxx'); },

Code: Select all

         success: function (quizzes) {}, 
         type: "GET", 
         error: function () {}, 
     }); 

/code/pre

Thanks heaps.

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Multiple values for "where" in one database query

Hello!

codevar whereClause = {"Maker":{"$in": ["Samsung","Nokia"]}, "model":"Galaxy Note III"};

$.ajax({
dataType: 'json',
data: "where="+encodeURI(JSON.stringify(whereClause)),
url: 'https://api.tiggzi.com/rest/1/db/collections/xxx',
beforeSend: function (xhr) {
xhr.setRequestHeader('X-Tiggzi-Database-Id', 'xxxx');
},
success: function (quizzes) {},
type: "GET",
error: function () {}
});/code

Joseph Yeung
Posts: 0
Joined: Tue Aug 14, 2012 7:48 am

Multiple values for "where" in one database query

Thanks alooooooooooot!!

Joseph Yeung
Posts: 0
Joined: Tue Aug 14, 2012 7:48 am

Multiple values for "where" in one database query

Hi,

It was promising, but did not work out, with the returning response being 500 internal server error.

The question remains how to translate the following (underlined) cURL command into jquery:

Any thought is much appreciated.

Image

Joseph Yeung
Posts: 0
Joined: Tue Aug 14, 2012 7:48 am

Multiple values for "where" in one database query

Sorry, any reply on the above?

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Multiple values for "where" in one database query

Hello! Here is how to translate it into jQuery:

$.ajax({
data: encodeURI('where={"priority":"high"}'),
...
})

If you'll have server returning any error, you should check description of the error using Firebug or Chrome Developer Console (Network tab)

Joseph Yeung
Posts: 0
Joined: Tue Aug 14, 2012 7:48 am

Multiple values for "where" in one database query

I did check it out. Besides 500 internal server error, it said missing database id, which did not make much sense.

Return to “Issues”