Make it possible to query mongo document by _id

This commit is contained in:
Jan Oberhauser 2021-09-04 16:30:12 +02:00
parent 1084e7d9b5
commit 66482425da

View file

@ -71,9 +71,15 @@ export class MongoDb implements INodeType {
// ---------------------------------- // ----------------------------------
try { try {
const queryParameter = JSON.parse(this.getNodeParameter('query', 0) as string);
if (queryParameter._id && typeof queryParameter._id === 'string') {
queryParameter._id = new ObjectID(queryParameter._id);
}
let query = mdb let query = mdb
.collection(this.getNodeParameter('collection', 0) as string) .collection(this.getNodeParameter('collection', 0) as string)
.find(JSON.parse(this.getNodeParameter('query', 0) as string)); .find(queryParameter);
const options = this.getNodeParameter('options', 0) as IDataObject; const options = this.getNodeParameter('options', 0) as IDataObject;
const limit = options.limit as number; const limit = options.limit as number;