casbin/mongodb-adapter

Do we need to .SavePolicy?

mukill opened this issue · 4 comments

What is the point of using .SavePolicy when Add, Update, and Remove all seem to save the new lines to the db?

The enforcer is in memory, do savePolicy() save to DB for persistence. If you don't need persistence, don't do savePolicy()

@imp2002 it looks like we save to the db on each CUD action though from reading the source code? Isn't it redundant to also call save policy?

@mukill if your adapter supports Auto-Save, then you don't need to manually call SavePolicy(), see: https://casbin.io/docs/adapters#autosave