prisma-adapter
prisma-adapter copied to clipboard
Order of policies stored in DB after a.savePolicy is not same as source
Order of policies in DB after savePolicy is not same as in source file: examples/rbac_policy.csv
Sample test: https://github.com/node-casbin/prisma-adapter/blob/master/test/adapter.test.ts Code snippet: line 40-50
try {
// Because the DB is empty at first,
// so we need to load the policy from the file adapter (.CSV) first.
let e = await newEnforcer(
'examples/rbac_model.conf',
'examples/rbac_policy.csv'
);
// This is a trick to save the current policy to the DB.
// We can't call e.savePolicy() because the adapter in the enforcer is still the file adapter.
// The current policy means the policy in the Node-Casbin enforcer (aka in memory).
await a.savePolicy(e.getModel());
@nodece @Shivansh-yadav13