Page 1 of 2

Query Collection by Month

Posted: Fri Feb 14, 2014 8:34 pm
by Bad Addy

I have looked at the docs about date queries, but I cannot see if we can spilt the string, within the query, so it gives me results based on a month ?


Query Collection by Month

Posted: Fri Feb 14, 2014 9:20 pm
by Kateryna Grynko

Hi,

Here is an example of query by day: https://getsatisfaction.com/apperyio/...


Query Collection by Month

Posted: Fri Feb 14, 2014 9:33 pm
by Bad Addy

Thank you, but that does not answer my question. I cannot query any month based on that, without a complex query on a WHERE statement ?


Query Collection by Month

Posted: Fri Feb 14, 2014 10:21 pm
by Kateryna Grynko

Addy,

You will need it. Let's try. Write a query based on this example. If this doesn't work just post your code here and we'll help.


Query Collection by Month

Posted: Sat Feb 15, 2014 11:17 am
by Bad Addy

Here is the code, no errors, but I get no results either:

precode
where:{"sid":6, "_createdAt" : {"$gt" : "2014-02-01 00:00:00.000" , "$lt" : "2014-02-28 00:00:00.000"}}
/code/pre

The above is the output, of what the URL is sending. Its giving me no errors.


Query Collection by Month

Posted: Sat Feb 15, 2014 12:12 pm
by Illya Stepanov

Hi Addy - try to describe all JSON object values with quotes:
pre
where:{"sid":"6", "_createdAt" : {"$gt" : "2014-02-01 00:00:00.000" , "$lt" : "2014-02-28 00:00:00.000"}}
/pre


Query Collection by Month

Posted: Sat Feb 15, 2014 12:45 pm
by Bad Addy

no, you mean JSON.stringify ?


Query Collection by Month

Posted: Sat Feb 15, 2014 1:00 pm
by Bad Addy

This is the code output:

precode
where:{"$and" : [{"sid":6}, {"_createdAt" : {"$gt" : "2014-02-01 00:00:00.000" , "$lt" : "2014-02-28 00:00:00.000"}}]}
/code/pre

And this is how I get it:

precode
var querydate;
var date = new Date(),
y = date.getFullYear(),
m = date.getMonth(),
firstDay = new Date(y, m, 1),
lastDay = new Date(y, m + 1, 0),
querydate = '"_createdAt" : {"$gt" : "' +
myFormat(firstDay) + '" , "$lt" : "' +
myFormat(lastDay) + '"}';

$.ajax({
type: 'GET',
beforeSend: function(request) {
request&#46;setRequestHeader('X-Appery-Database-Id', '<db_ID>');
},
url: 'https:&#47;&#47;api&#46;appery&#46;io/rest/1/db/collections/questions',
dataType: 'json',
data: {
where: '{"$and" : [{"sid":'+sid+'}, {'+querydate+'}]}'
},
success: function(res) {
$('#source_monthlyQcount_box')&#46;text(res[0]&#46;count);
}
});

/code/pre

It looks fine to me, but i get no results, and no errors?


Query Collection by Month

Posted: Sat Feb 15, 2014 4:00 pm
by Bad Addy

Any ideas why its not bring any data ?


Query Collection by Month

Posted: Sat Feb 15, 2014 4:41 pm
by Alena Prykhodko

Hello, sorry, but this needs additional time, we'll get back as soon as possible.