# casequelize

> Casbin Sequelize adapter for Node-Casbin

Latest version **1.1.0** (published 2018-08-30) · 0 weekly downloads

## Install

```sh
npm install casequelize
pnpm add casequelize
yarn add casequelize
bun add casequelize
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2018-08-30 |
| First published | 2018-08-19 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 25.7 KB |
| Known vulnerabilities | 0 (+5 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Node-Casbin |
| Maintainers | chalin |
| Keywords | casbin, node-casbin, adapter, sequelize, access-control, authorization, auth, authz, acl, rbac, abac, orm |

## Links

- npm: https://www.npmjs.com/package/casequelize
- Repository: https://github.com/Chalin-Shi/casequelize
- Homepage: https://casbin.org
- Issues: https://github.com/node-casbin/casequelize/issues
- npm.io page: https://npm.io/package/casequelize

## Dependencies (2)

- [casbin](https://npm.io/package/casbin.md) ^1.1.2
- [sequelize](https://npm.io/package/sequelize.md) ^4.38.0

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.1.0 (latest) — 2018-08-30
- 1.0.0 — 2018-08-19

## README

Casbin Sequelize Adapter
====

Casbin Sequelize Adapter is the [Sequelize](https://github.com/sequelize/sequelize) adapter for [Casbin](https://github.com/casbin/node-casbin). With this library, Casbin can load policy from Sequelize supported database or save policy to it.

Based on [Officially Supported Databases](http://docs.sequelizejs.com), The current supported databases are:

- MySQL
- PostgreSQL
- Sqlite3
- Mssql

You may find other 3rd-party supported DBs in Sequelize website or other places.

## Installation

    npm install casequelize

## Simple Example

```javascript
const Adapter = require('casequelize');
const { Enforcer } = require('casbin');

module.exports = () => {
	// Initialize a Sequelize adapter and use it in a Casbin enforcer:
	// The adapter will use the MySQL database named "casbin".
	// If it doesn't exist, the adapter will create it automatically.
  
  const adapter = await Adapter.newAdapter('mysql://root:123456@localhost:3306/casbin', {}); // Your driver and data source.
  const enforcer = await Enforcer.newEnforcer('examples/rbac_model.conf', adapter);
	
	// Or you can use an existing DB "abc" like this:
	// The adapter will use the table named "casbin_rule".
	// If it doesn't exist, the adapter will create it automatically.
	// adapter = sequelizeadapter.newAdapter("mysql", "mysql_username:mysql_password@tcp(127.0.0.1:3306)/abc", true)

	// Load the policy from DB.
	await enforcer.loadPolicy()
	
	// Check the permission.
	await enforcer.enforce('alice', 'data1', 'read')
	
	// Modify the policy.
	// e.addPolicy(...)
	// e.removePolicy(...)
	
	// Save the policy back to DB.
	await enforcer.savePolicy()
}
```

## Getting Help

- [Casbin](https://github.com/casbin/node-casbin)

## License

This project is under Apache 2.0 License. See the [LICENSE](LICENSE) file for the full license text.

---
_Source: https://npm.io/package/casequelize · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
