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 an 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":{"modifiedAtcreatedAt":-1}} will sort the data items shown in the result array based on the modified created date displaying the latest modified created data item first.

The following image shows the result payload.

...

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

...

1

The below example will return all the values that have the status as Inactive, age greater than 32, and whose page number equals the dynamic 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 query requests, in case you make a mistake and created an infinite loop. Then either change changes the delay to 1 ms or remove the delay completely.

...

The Dynamic Data Manager node is set to Read. The AND condition of version, CreatedAt, Page limit says for this page do not bring back more than is set for status and age.

The number of documents per page is 999 items. Which is the max limit.

...

In sortBy, we used createdAt. You can also use modifiedAt.

The createdAt, modifiedAt, and _id are always returned in the collection.

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

The init function node sets , set up the pagePntr to start at 1. A common mistake is to start at 0.
Also setting up the array to store the results, in this case, msg.userDataArray = [ ]

...

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;

The loop function node concatenates the results of each page until it collects all the data.

...