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:
I would recommend checking the following:
Check the Schema tab and seeing if there's anything about your documents that doesn't fit the configured schema. The schema has a default configuration that may not match the actual schema of your documents. You may need to modify this schema to get the update working.
Click the edit button (the pencil) on the 'default' role, and check the "Apply When" of the role. It's possible that the document you're trying to update does not match any role, and that the role needs updating.
If that doesn't work, check the application logs by clicking the "Logs" button on the sidebar: Logs tab
There you can see the "update not permitted" error but with more details about why the update failed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With