skip to content
Alvin Lucillo

No write privilege

/ 1 min read

In Atlas, you can assign database user privileges. The account used below only has Only read any database built-in role. There are more granular privileges, such as specifiying a cluster or a combination of role, database, and collection.

The error below is due to a write attempt by the user without write access.

Atlas atlas-d4991z-shard-0 [primary] sample_mflix> db.users.findOne({})
{
  _id: ObjectId('59b99db4cfa9a34dcd7885c7'),
  name: 'John Carter',
  email: 'john_carter@example.net',
  password: '$2b$12$VSEGxtSVpzG1DSrHOL1MaP1IN0kMigVDOOJK0SKBrNVR85dsKM2Wv'
}
Atlas atlas-d4991z-shard-0 [primary] sample_mflix> db.users.deleteOne({})
MongoServerError[AtlasError]: user is not allowed to do action [remove] on [sample_mflix.users]