node_acl icon indicating copy to clipboard operation
node_acl copied to clipboard

How to use acl with mongoose

Open ghost opened this issue 9 years ago • 1 comments

Hey,

// I create a pastebin of the code: http://pastebin.com/2MVuMmM8 // I dont know why its not format here... with Mongo i do this:

mongoose.connect("mongodb://localhost:27017/xeorMain", function(err) { if (err) { console.log("ERROR");

}
acl = new acl(new acl.mongodbBackend(mongoose.connection, 'acl_'));
acl.allow('guest', 'blogs', 'view');
acl.allow('admin', 'blogs', 'edit');

});

and in mongoose i try this:

mongoose.connect("mongodb://localhost:27017/xeorMain", function(err) { if (err) { console.log("ERROR");

}
acl = new acl(new acl.mongodbBackend(mongoose.connection, 'acl_'));
acl.allow('guest', 'blogs', 'view');
acl.allow('admin', 'blogs', 'edit');

});

but this doesn't work. Is the acl param wrong with "mongoose.connection"?

Greetz

ghost avatar Aug 12 '16 22:08 ghost

Do not use mongoose.connection as db instance - it has a type NativeConnection (realized interface MongooseConnection). The right way:

javascript var acl = new ACL.mongodbBackend(mongoose.connection.db);

designeng avatar Aug 18 '16 11:08 designeng