Moving to node-red-contrib-mongodb4
and I'm having issues.
I can perform a find
operation, but I cannot for the life of me pass in any options like $sort
or $limit
From a function node, I setup the collection and operations:
msg.collection = "foo";
msg.operation = "find";
I try two types of methods in attempt to implementing the options:
method #1:
const options = {
$sort : { "_id" : -1 },
$limit : 1
}
msg.payload = [
msg.searchQuery,
options
];
and this function node passes the msg to a node-red-contrib-mongodb4
node,
which performs the find, but returns all documents.
I've also tried to do so by method of it's processor : node-red-contrib-mongodb
(which worked well)
by tacking on the msg
object:
method #2:
msg.payload = msg.searchQuery
msg.sort = { "_id" : -1}
msg.limit = 1
return msg;
Still neither of these methods work for me and are still returning the full set of documents, and not limiting the return.
I just can't seem to get these find
options to work.
Not sure what I'm doing wrong here.