I keep getting, Missing ";" before statement
error in Mongodb Atlas Online. I am new to this, and I fail to see why the following lines gives this error:
const counter = await counterCollection.findOneAndUpdate({_id: changeEvent.ns },{ $inc: { seq_value: 1 }}, { returnNewDocument: true, upsert : true});
AND:
const updateRes = await targetCollection.updateOne({_id: docId},{ $set: doc});
Full code:
exports = function(changeEvent) {
const docId = changeEvent.fullDocument._id;
const counterCollection = context.services.get("Cluster0").db(changeEvent.ns.db).collection("counters");
const targetCollection = context.services.get("Cluster0").db(changedEvent.ns.db).collection(changeEvent.ns.coll);
const counter = await counterCollection.findOneAndUpdate({_id: changeEvent.ns },{ $inc: { seq_value: 1 }}, { returnNewDocument: true, upsert : true});
const doc = {};
doc[`${changeEvent.ns.coll}Id`] = counter.seq_value;
const updateRes = await targetCollection.updateOne({_id: docId},{ $set: doc});
console.log(`Updated ${JSON.stringify(changeEvent.ns)} with counter ${counter.seq_value} result: ${JSON.stringify(updateRes)}`);
};