1

How can we make unique keys in collection ? any expressions or rules for it ?

Also i have created a collection users for user info and there is a field named role i want that only admin can update that field value. any suggestion how can i achieve that ?

Muhammad Furqan
  • 324
  • 3
  • 16

1 Answers1

0

For unique keys please see: https://docs.mongodb.com/manual/core/index-unique/

In regards to restricting updating a certain field, that needs to be handled in your application by checking user permissions before sending an operation to your MongoDB database.

If you need to restrict things at the database level as well, please see: https://docs.mongodb.com/manual/core/authorization/

Aaron Rumery
  • 552
  • 2
  • 9
  • I am talking about MongoDB Stitch. – Muhammad Furqan Mar 28 '18 at 09:15
  • On their marketing page it says: "All of MongoDB Unlike other backend offerings, get the full power and scalability of MongoDB – whether using your existing database or starting from scratch. Retain direct access to the database." so you should be able to do anything MongoDB does with this service. So both indexing and authorization from the core of MongoDB should be available to you. If not, you should speak directly with MongoDB as Stitch is still in beta. – Aaron Rumery Mar 29 '18 at 09:17
  • For Stitch related documentation, refer to https://docs.mongodb.com/stitch/ – Aaron Rumery Mar 29 '18 at 09:19
  • I know. I have spent much time to reading documentation and have not found any solution for these things. thats why i asked here. – Muhammad Furqan Mar 29 '18 at 11:42