Update not allowed in MondoDB Realm

Hi everyone!

I’m using MongoDB Realm and Angular as a framework. I can create, read and delete documents with queries/mutations of GraphQL and using the API of MongoDB Data Access but I cannot update the documents.

I tried with the GraphQL endpoint and I can use the upsertOneUser but not the updateOneUser (and the others update functions). It says that it is not allowed. Also using the collections it does not work.

Whare is the problem? I have all the permission for write/read/insert documents.

1 Like

Did you ever figure this out?

@Try_Catch_Do_Nothing @Giacomo_Ondesca
There could be several reasons why you are not able to update documents in MongoDB Realm using GraphQL or the Data Access API. Here are a few things to check:

  1. Make sure that your MongoDB Realm app’s rules allow updates. You can check this in the MongoDB Realm UI by going to your app, selecting “Rules” from the left-hand menu, and checking the “Update” permission for the relevant collection.

  2. Make sure that you are passing the correct parameters to the updateOneUser mutation. The mutation requires an “input” parameter that specifies the filter to identify the document to update, and a “set” parameter that specifies the fields to update. Here is an example:

mutation {
  updateOneUser(input: {filter: { _id: "user123" }, set: { name: "New Name" }}) {
    _id
    name
  }
}

This would update the “name” field of the user with ID “user123” to “New Name”.

  1. Check the permissions of the user making the update. Make sure that the user has the correct role and permissions to update documents in the relevant collection.

If none of these solutions work, you may want to reach out to MongoDB support for further assistance.