Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • limit” specifies the number of data items to be shown per page in the result object. The maximum value is 999. Always specify a limit. If you do not specify a limit and there are more than 999 results, it will return invalid number of results.

  • page” is the page number to be shown in the results object. The first page starts at 1.

  • sortBy” is used to sort the fetched data based on the criteria.
    For example, {"sortBy":{"modifiedAt":-1}} will sort the data items shown in the result array based on the modified date displaying the latest modified data item first.

...

Item Name is asked while creating the Data item manually. Multiple data items can have the same item name. You can query the data using the item name.

...

Example Read: How to read with Paging, Greater than, AND

Return all the values who are version, 1, and the createdAt date was greater than 20 days, whose page number equals the value passed to the data manager.

If there are more than 999 items we need to concatenate the results.

Because we are doing a loop to get all the pages of data, it is a good idea while testing to add a delay to throttle the number of queries done, in case you make a mistake and created an infinite loop. Then either change the delay to 1 ms, or remove the delay completely.

...

Ignore the red X in this example, the validation is confused by the mustache tag, it is ultimately a number

Code Block
{
  "version": "1",
  "createdAt": { "$gt" : "{{msg.startDate}}" },
  "limit": 999,
  "page": {{msg.pagePntr}},
  "sortBy": {"createdAt":-1}
} 

...

Code Block
msg.pagePntr = 1;  // init page pointer to 1
msg.userDataArray = [];  // init aray
var moment = global.get('moment');
const now = moment();  // use moment to creat time 20 days earlier than today
const DaysAgo = now.subtract(20, "days").startOf("day").utc().toISOString();
node.warn(DaysAgo);  // "2020-11-16T00:00:00.000Z"
msg.startDate = DaysAgo;
return msg;

Image Added

Code Block
var userData = msg.data.dynamicData.result;  // Get the results from dynamic data node.
if (userData.length > 0) {   // is there any data.
    msg.userDataArray = msg.userDataArray.concat(userData);  // append to the last array.
    msg.pagePntr = parseInt(msg.pagePntr) + 1;  // increment the page pointer.
    node.warn('Next page ' + msg.pagePntr);
    if(msg.data.dynamicData.paging.hasMore.hasNext === false) {   // is there another page. if not exit loop
       return [null,msg]    
    } else {
        return [msg,null]  // get the next page of data.
    }
} else {
    return [null,msg]   // no data
}

Example Read, OR condition, AND, NOT Equal

Image Added

Code Block
{
"$or": [{"runStatus": "start"}, {"acknowledge": "yes"}],    
  "runStatus": { "$ne": "Complete" },
"limit": 900,
"page": 1,
"sortBy": {"createdAt":-1}
} 

Create

Lets you create a new data item. If you don’t specify a project ID in the payload, the data is created as Global data.

...