Reputation: 5818
As per documentation of Mongoose, there is no way to create a role with MongoDB.
I want to perform role creation with MongoDB
db.createRole()
Though, I could see some external libraries doing a similar approach but not exactly the same as above and also some of those are not maintained
Any best approach for this?
Upvotes: 1
Views: 170
Reputation: 583
In node js you can achieve it like this
await db.command({
createRole: 'newTestRole',
privileges: [
{ resource: { role: "read", db: 'dbname', collection: "my_collection" }, actions: ["find"] }
],
roles: []
});
Upvotes: 1