0

Is there a way to prevent deletion of objects in a mongoDB collection using a constraint or something else?

Maybe you are thinking: Why he doesn't prevent it in his code? Well I'm having an issue with a conflicting package (GroundDB) in my meteor/mongo app which delete records temporarily when syncing after and offline/online period. I need to dig into the issue but so far I want to workaround the issue. Actually it would be good to completely block deletion in that collection, since the user nor the administrator never requires to purgue that data (It's a kind of permanent log).

Thanks in advance.

Ruben
  • 816
  • 1
  • 8
  • 21
  • 1
    Assuming you are using authentication (and if you aren't, please do!) you could perhaps [create a custom role](https://docs.mongodb.com/manual/tutorial/manage-users-and-roles/#create-user-defined-role) with more limited privileges. However, it sounds like you want to limit the access for a rogue package that you are loading into your Meteor app and would be better addressing the code issue. You might be better served editing this question to include details of the specific package version and behaviour you are trying to fix ;-). – Stennie Jul 16 '17 at 03:16
  • Your last comment on a workaround also needs clarity around "the server collection never purge any records". – Stennie Jul 16 '17 at 03:17
  • This question is better suited for [serverfault](https://serverfault.com/) – Michel Floyd Jul 16 '17 at 03:22
  • @Stennie: The package is GroundDB. I added some clarity where you pointed out. – Ruben Jul 17 '17 at 00:47
  • 1
    If the deletion is from client side, you can simple apply [Deny](https://docs.meteor.com/api/collections.html#Mongo-Collection-deny) on the collection. – Sudheer Jami Jul 17 '17 at 01:55
  • Thank you @Deny, I think that is the way to go... – Ruben Jul 19 '17 at 14:50

0 Answers0