Page 3 of 3

Query a date range.

Posted: Tue Oct 21, 2014 12:45 am
by Yurii Orishchuk

Hi Mike,

It seems you have wrong "date" field type.

You should have "Date" type.

See details: http://prntscr.com/4y6bzd/direct

If you have here "string" you can not sort this value as date.

After you will get in your "date" response field something like this: http://prntscr.com/4y6cww/direct

Regards.


Query a date range.

Posted: Tue Oct 21, 2014 2:52 pm
by Mike6979865

The problem is I already have alot of data... How do I change the column from String to Date. I'm not able to edit and I have hundreds of records...


Query a date range.

Posted: Tue Oct 21, 2014 3:39 pm
by Mike6979865

Can I use _CreatedAt instead? I tried it,and it didn't work.


Query a date range.

Posted: Wed Oct 22, 2014 2:59 am
by Yurii Orishchuk

Hi Mike,

You can not edit existent column type.

But it's easy to delete current column and create new column with type you need.

Yes you can use "createdAt" field as well as "updatedAt" field.

But here is some difference.

Base query string is:

pre

{"_createdAt": {$gt: {"$date": "2011-04-15T00:32:22.883Z"} } }

/pre

So code should be:

pre

var d1 = new Date(Apperyio("startDate").datapickerRoot.find("input").val()).toISOString().replace(/T.*/gi, "") + "T00:00:00.000Z";

var d2 = new Date(Apperyio("endDate").datapickerRoot.find("input").val()).toISOString().replace(/T.*/gi, "") + "T00:00:00.000Z";

var whereObject = {
$and: [{
"createdAt": {
$gt: {
"$date": d1
}
}
}, {
"createdAt": {
$lt: {
"$date": d2
}
}
}]
};
return JSON.stringify(whereObject);

/pre

Regards.


Query a date range.

Posted: Wed Oct 22, 2014 2:46 pm
by Mike6979865

Thank you for the code. I tried that, and I saw the loading indicator load for 10 seconds but then I didn't see the addresses being mapped on the map (i.e no markers).

Also, before, I clicked on List All, and I was able to see the addresses being marked on the map. Now, it's not working for some reason... Is it because the database in large now? It worked perfectly fine in the last few days.


Query a date range.

Posted: Thu Oct 23, 2014 2:10 am
by Yurii Orishchuk

Hi Mike,

It's hard to say what is wrong.

At first you can just set "limit" parameter for you "list" service with value for example: "10".

Then please take a look into browser debugger network tab and find there your request. Open response tab and see what is here.

Regards.


Query a date range.

Posted: Thu Oct 23, 2014 3:48 pm
by Mike6979865

It worked!

The marker "visible" property was not checked. Thank you so much!