casbin / mongodb-adapter

MongoDB adapter for Casbin

Home Page:https://github.com/casbin/casbin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Question] Purpose of LoadPolicy() and SavePolicy() methods

Googlom opened this issue · comments

Hi. I wonder what is the purpose of LoadPolicy() and SavePolicy() methods here in mongo adapter if Enforce() reads directry from db and there is AddPolicy() method which writes directly to db?

@Googlom AutoSave is an optional feature and when it's unavailable, an adapter has to use LoadPolicy() and SavePolicy() and interact with DB.

When you use an adapter that supports AutoSave, you will only use LoadPolicy() to load all rules first, then use AddPolicy() or RemovePolicy() to modify rules. SavePolicy() is usually not used.