Encountering an issue when trying to retrieve the "createdAt" property in Cloud Code using the Parse Framework

I am working with Cloude Code to develop a more complex query, but I am having trouble accessing the automatically created "createdAt" property by Parse. Here is my code:

Parse.Cloud.define("get_time", function(request, response)
{
    var query = new Parse.Query("Test");
    var today = new Date(); // retrieves today's date
    var thirdDaysAgo = new Date(today - 1000 * 60 * 60 * 24 * 30); // retrieves the date from 30 days ago
    var threeHoursAgo = new Date(today - 1000 * 60 * 60 * 1); // retrieves the date from 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 only storing null objects.

Answer №1

Initially, it is important to note that using greaterThan multiple times on the same field will only result in the last one being effective.

Additionally, you mentioned that the results are populated with null objects, indicating that it returns an array of results, correct?

Is it results that contains null values, or is it finalArray? Keep in mind that objectId, createdAt, and modifiedAt cannot be accessed through get("columnName"); they are intrinsic properties requiring results[i].createdAt instead. Therefore, finalArray may appear full of nulls due to this reason.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the reason behind Express serving the static file through the router, while also causing the path to the scripts folder to

Directory Layout app ├── app.js ├── public │   ├── data │   │   └── data.json │   ├── index.html │   └── js │   ├── filter-list.js └── routes └── index.js Setting up ap ...

retrieve the array elements that came before in a foreach loop

Here is an example code snippet: $arr = array("jan","feb","mar","apr","mei","jun","jul","agu","sep","okt","nov","des"); Followed by a foreach loop: foreach($arr as $ar){ echo $ar; } This will output the values from jan to des. My query is: How can I ...

Utilizing Server-Sent Events to display a interactive navigation button

Currently, I am managing a web-based point of sale system where some buttons are hidden for specific functions. To streamline the process, I would like to allow managers to simply click on an "Enable" button in the admin panel and have it immediately refle ...

Encountering a 404 Error on all routes except the home page when working with the Express Application Generator

While working on developing a day planner, I encountered an issue with the routes. I am consistently receiving a 404 error for any route other than the main Home page route (index or "/"). Below is the content of the app.js file: var express = require(&ap ...

Implement a transition effect for when elements change size using the `.resizable().css` method

I attempted to incorporate a deceleration effect when resizing an element back to its original size using the resizable method. The slowdown effect should only trigger during the click event (when the "Click-me" button is pressed), not while manipulating ...

Arranging strings in a string array in alphabetical order

I need to find a way to insert a string (from a cell) into a string array in alphabetical order. For example: string array = {"apple", "banana", "orange"} insert "cherry": string array = {"apple", "banana", "cherry", "orange"} So if I use sheets(1).ra ...

ReactForms Deprication for NgModel

According to Angular, certain directives and features are considered deprecated and could potentially be removed in upcoming versions. In a hypothetical scenario, let's say I am using NgModel with reactive forms, which Angular has marked as deprecate ...

Developing a dynamic web application using the Django framework along with the Vue.js library and Highcharts for

I am currently working on a data visualization web app using Django, Highcharts, and JQuery. I have recently transitioned from JQuery to Vue JS and I am struggling with fetching JSON data from a specific URL. Below is the code snippet: Template <!doc ...

Utilizing an Ajax call within "for" loops can result in skipping either odd or even iterations

Seeking assistance because we are facing a challenge that we cannot seem to overcome. Despite researching on platforms like StackOverflow and search engines, implementing a solution or solving the problem remains elusive. The goal is to develop a JavaScri ...

Understanding the response from an AJAX call

VB code Dim temp3 As String = dt.ToString() cmd.Connection = con con.Open() i = cmd.ExecuteNonQuery() con.Close() If i = 1 Then msg = "Record successfully inserted" ...

Express.js allows users to define a parent root folder domain

My Express Node.js application is structured as follows: app.get('/', page.index); //Add new, edit and delete form app.get('/approval', page.approval); //Task to approve/reject the subordinate form app.get('/task', page.task ...

What is the best method for starting a string using the symbol '~'?

Hello everyone! I have a task that requires me to add a special feature. The user needs to enter something in a field, and if it starts with the tilde (~), all subsequent entries should be enclosed in a frame within the same field or displayed in a list ...

How to extract a specific part of a string with regular expressions

I am currently working on a function to search for a specific substring within a given string. // the format is <stringIndex>~<value>|<stringIndex>~<value>|<stringIndex>~<value> var test = "1~abc1|2~def2|1~ghi3|4~jk-l4 ...

Sophisticated jQuery templates

Working with jQuery templates can be straightforward for basic data structures. <script type="jquery/x-jquery-tmpl" id="myTemplate"> <li> ${Element} </li> </script> var elements = [ { Element: "Hydrogen" }, { Element: "Oxy ...

Transferring the AJAX response into a JavaScript variable

New to AJAX and JS here. I am implementing an AJAX code that fetches data from a php service. I am trying to figure out how to store the returned data in a JavaScript variable, which I can then display on the UI. Below is my AJAX code snippet: <script ...

Decoding multidimensional arrays in JSON using PHP

I am extracting information from the following website: "" and converting it into JSON format using a PHP script. The JSON output appears as follows: ( [Term-array-array] => Array ( [Term-array] => Array ( [Term] => Array ( [0] => loves [1] = ...

Ways to showcase an alert or popup when clicking?

I am utilizing a date picker component from this site and have enabled the 'disablePast' prop to gray out past dates preventing selection. Is there a way to trigger an alert or popup when attempting to click on disabled days (past dates)? Any sug ...

Exploring the benefits of looping with node.js require()

Currently, I have defined the required files as shown below. constantPath = './config/file/' fileAA = require(path.resolve(constantPath + 'A-A')), fileBB = require(path.resolve(constantPath + 'B-B')), fileCC = require(path.r ...

The attempt to install "expo-cli" with the command "npm install -g expo-cli" was unsuccessful

Encountered an issue while trying to install expo-cli for creating android applications using npm install -g expo-cli. NPM version: 7.19.1 Node version: v15.14.0 Upon running npm install -g expo-cli, the installation failed with the following error mess ...

Having difficulty locating the index of the column labeled `Clients` within a table; the result being -1

Having some trouble locating the index of the column name Customers within a table using jQuery/javascript. No matter what I try, it always returns -1 let tableDatacy = "Results_Table"; let columnName = "Customer"; let tableHeaders = [] ...