What are best practices for immutable inserts? A transaction log collection, for example? Disabling update by user or database collection

What is a best practice for having a collection that I effectively want to be append only?

I’d like to record transactions into a ledger where I can insert and not update or delete (for any user, ideally).

What general recommendations are there for this scenario? I searched for existing threads, but please point me to one if this has already been discussed.

Thank you!
Jeremy

Hi @Jeremy_Buch and welcome back :smiley: !

I think I would create a user and limit its permissions. I would create a custom role with the actions find and insert on the resources (db or collections) you need.

Cheers,
Maxime.

1 Like

Thanks Maxime! I saw a discussion about limiting the actions that users can take and this approach can definitely solve the problem from a management perspective based on permissions.

Thanks for confirming!

Jeremy

PS - thanks! I built out a MongoCDC implementation last year early summer and haven’t had to dig into mongo more since then until now.

1 Like

If you are running on Atlas, you need to create a custom role:

Then when you create the user, you can assign the custom role like this:

I hope this helps :+1:

Cheers,
Maxime.

2 Likes

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.