Knex Adapter
Knex Adapter for Node-Casbin. Use this library for policy storage in Casbin.
For full database support list, go to the Knex documentation.
Installation
npm install casbin-knex-adapter --save
or
yarn add casbin-knex-adapter
Example
const Knex = require('knex')
const casbin = require('casbin');
const KnexAdapter = require('casbin-knex-adapter');
(async function() {
const knex = Knex(knexOptions)
const adapter = await KnexAdapter.newAdapter({ knex });
const enforcer = await casbin.newEnforcer('model.conf', adapter);
await enforcer.loadPolicy();
if (await enforcer.enforce('user', 'resource', 'read')) {
}
await enforcer.savePolicy();
})();