Reputation: 763
I'm using Cloude Code to create a query a little more complex, but i cant access, the property that is automatically created by Parse "createdAt", heres my code :
Parse.Cloud.define("get_time", function(request, response)
{
var query = new Parse.Query("Test");
var today = new Date(); // gets today
var thirdDaysAgo = new Date(today - 1000 * 60 * 60 * 24 * 30); // gets 30 days ago
var threeHoursAgo = new Date(today - 1000 * 60 * 60 * 1); // gets 3 hours ago
query.greaterThan("createdAt", thirdDaysAgo);
query.greaterThan("createdAt", threeHoursAgo);
query.descending("createdAt");
query.find({
success: function(results)
{
if(results.length > 0)
{
var finalArray = [];
for (i = 0; i < results.length; i++)
{
var dataCreated = results[i].get("createdAt");
finalArray.push(dataCreated);
}
response.success(finalArray);
}
},
error: function()
{
response.error("time lookup failed");
}});
});
The finalArray, is filled only with null objects.
Upvotes: 0
Views: 424
Reputation: 16884
First off you can't use greaterThan
twice on the same field, the last one is the only one that will stick.
Secondly you say that results is filled with null objects, so it is returning an array of results then?
Is it results
that is full of nulls, or is it finalArray
. You should be aware that objectId
, createdAt
and modifiedAt
aren't available via get("columnName")
, they are native properties so you have to use results[i].createdAt
instead. That is why finalArray
would be full of null values.
Upvotes: 1