How do i use the orderby field of the Node-RED api get:
get
Get items from a collection, based on a Mongo query
node-red : api get
specifically what would i enter to order the results by newest date in terms of workitems.
Greetings
How do i use the orderby field of the Node-RED api get:
get
Get items from a collection, based on a Mongo query
node-red : api get
specifically what would i enter to order the results by newest date in terms of workitems.
Greetings
Order either takes a field name or a comma-separated list of field names. But for full “control,” you can/should send a MongoDB order by clause, which is a JSON object containing the field name as a “key” and 1 or -1 for ascending or descending order.
// Ascending sort
{ "_created": 1 }
// Descending sort
{ "_created": -1 }
Can I send that in the order by field? If not where can I use this? Or do I have to program a function for it?
Yes, you put that in the orderby field.
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.