0.2.3 • Published 7 years ago

acl-knex v0.2.3

Weekly downloads
315
License
-
Repository
github
Last release
7 years ago

Node Acl KnexBackend

A Knex.js backend for node_acl

Knex is a query builder for PostgreSQL, MySQL and SQLite3 in Node, The Knex backend is to be used as an adapter for OptimalBits/node_acl.

BuildStatusCoverage StatusDependency StatusdevDependency Status

##Features & Documentation Please note that this library currently supports Postgres. MySql and SQLite support coming soon.

Please see OptimalBits/node_acl.

##Installation

Using npm:

npm install acl
npm install knex

npm install pg (for use with Postgres)
npm install mysql (for use with MySql, coming soon)
npm install sqlite3 (for use with SQLite, coming soon)

npm install acl-knex

Setup tables:

node setup.js <<db_name>> <<username>> <<password>> <<prefix>> <<db_host>> <<db_port>> <<db>> <<db_url>> <<options>>

<<db_host>>, <<db_port>> default to 127.0.0.1 and 5432 respectively
<<db>> should actually be a knex object (only prefix would be needed if you pass in the knex object)
<<db_url>> should be a connection string (only prefix would be needed if you pass in the connection string)
<<options>> defaults (allows you to change the tables names)
{
	meta: 'meta',
	parents: 'parents',
	permissions: 'permissions',
	resources: 'resources',
	roles: 'roles',
	users: 'users'
}

eg: node setup.js 'travis_ci_test', 'postgres', '12345', 'acl_'
eg: node setup.js 'travis_ci_test', 'postgres', '12345', 'acl_', 192.168.56.10, 5432

eg: node setup.js null, null, null, 'acl_', null, null, 'postgres://postgres:12345@192.168.56.10:5432/travis_ci_test'

typically passing db is for use within code (we use it for rebuilding acl in unit tests)
var createTables = require('node_modules/acl-knex/lib/databaseTasks').createTables;
createTables([
	null,
	null,
	null,
	'node_acl_',
	null,
	null,
	null,
	db,
	options
], function(err, db) {
	...
});

Or to include it in a script:

var acl_knex = require('acl-knex');
new acl_knex.setup(function() {
	...
});

#Quick Start

	Acl = require('acl');
	AclKnexBackend = require('acl-knex');
	knex = require('knex');

	var db = knex({
		client: 'postgres',
		connection: {
			host: '127.0.0.1',
			port: 5432,
			user: 'postgres',
			database: 'travis_ci_test'
		}
	});

	var acl = new Acl(new AclKnexBackend(db, 'postgres', 'acl_'));

#Testing

npm test

Follow me on Twitter thetrudel

0.2.3

7 years ago

0.2.2

10 years ago

0.2.1

10 years ago

0.2.0

10 years ago

0.1.9

10 years ago

0.1.8

10 years ago

0.1.7

10 years ago

0.1.6

10 years ago

0.1.5

10 years ago

0.1.4

10 years ago

0.1.3

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago