Query Collection by Month
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 ?
Catch up wih the Appery.io community on our forum. Here you'll find information on the lastest questions and issues Appery.io developers are discussing.
https://forum.appery.io/
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 ?
Hi,
Here is an example of query by day: https://getsatisfaction.com/apperyio/...
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 ?
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.
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.
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
no, you mean JSON.stringify ?
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.setRequestHeader('X-Appery-Database-Id', '<db_ID>');
},
url: 'https://api.appery.io/rest/1/db/collections/questions',
dataType: 'json',
data: {
where: '{"$and" : [{"sid":'+sid+'}, {'+querydate+'}]}'
},
success: function(res) {
$('#source_monthlyQcount_box').text(res[0].count);
}
});
/code/pre
It looks fine to me, but i get no results, and no errors?
Any ideas why its not bring any data ?
Hello, sorry, but this needs additional time, we'll get back as soon as possible.