I have a Stitch function that does a couple of things and I'm getting an error at this line:
try {
// voteAsObjectId is the Id of the photo to vote converted to BSON.ObjectId.
await db
.collection('photos')
.updateOne({ "_id": voteAsObjectId }, { "$inc": { votes: 1 }});
} catch (err) {
throw new Error("An error occurred while updating photo's votes:" + err);
}
The error is the following:
StitchError: update not permitted
It seems like a permissions related error, but I have some other functions in my app and they successfully run every .find
.insert
and .aggregate
queries to this collection, only the .updateOne
and .updateMany
operations are giving me problems.
My collection's permissions look like this:
This is my schema:
And here's a sample document: