Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create readonly mongoose/mongodb connection or protect schema from modifying/deleting object?

I have an application that connects to an existing database and retrieves some data from it. This app will use this database in read-only mode. Despite it is our code I would like to add 'fool-level' protection from modifying/deleting documents accidentally by other developers/myself in the future. Tried with pre hooks but it looks that there're different remove hooks, query, model, document, etc... But I couldn't achieve consistency in behavior for all types of removing queries, query, model, document, etc... Is there any appropriate solution to this task?

like image 878
Anatoly Avatar asked Dec 21 '25 18:12

Anatoly


1 Answers

Create a read-only user and connect through that user: https://sysadmins.co.za/create-read-only-users-in-mongodb/

like image 158
limco Avatar answered Dec 24 '25 11:12

limco



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!