Pav An Pav An - 1 year ago 112
Node.js Question

Running 'node_acl' with mongoose on ExpressJS

I am building an application on ExpressJS (similar to a blog). I am using mongoose for working with MongoDB.

I came to the point when I had to choose between various ACL modules, and decided to go with
node_acl. What confuses me is that it is using mongodb modules instead of mongoose.

According to the docs on the ACL GitHub it has to be used this way:

// Or Using the mongodb backend
acl = new acl(new acl.mongodbBackend(dbInstance, prefix));

What would be an instance of db if I'm using mongoose?

I use something like:
Account = mongoose.model('Account', new Schema({ ... }));

Answer Source

Off the top of my head, I think you are looking for this:

Example (not tested):

var mongoose = require('mongoose'),
    acl = require('acl');

acl = new acl(new acl.mongodbBackend(mongoose.connection.db, 'acl_'));

(This is of course assuming you have initialized Mongoose elsewhere with mongoose.connect().)