I've been trying for hours to make this simple query work, but somehow it doesn't. I've created a HTTP service in MongoDB Stitch and I call the service with an ID like this
https://stitchurl.myservice?ID=blablabla
inside the service I want to disable the account with ID x so I tried to call it like this:
exports = function(payload) {
var queryArg = payload.query || '';
var ID = queryArg.ID || '';
if(ID !== "")
{
const mongodb = context.services.get("mongodb-atlas");
const mycollection = mongodb.db("myDB").collection("myCollection");
var oID = new BSON.ObjectId(ID);
return mycollection.updateOne({oID}, {$set:{isdisabled: true}});
}
}
no matter if I query:
{ID}
{oID}
{_id:ID}
{_id:oID}
...
I always receive 0 results, but when I'm in the MongoDB Atlas collections I can query for
{_id:ObjectId("myID")}
and receive the proper result. There's no problem with rules or rights, because if I run
return mycollection.findOne({})
I get a proper hit.
Any ideas what I'm doing wrong?
Regards Christian