Я использую модуль ACL с mongodb, я определяю некоторые роли и их разрешения с помощью функции acl.allow ().
const node_acl = require('acl');
const mongodb = require('mongodb');
let acl = null;
mongodb.connect(config.db.uri, (error, db) => {
if (error) {
throw error;
}
console.log('connected ..........',config.db.uri,db); // running successfully
var mongoBackend = new node_acl.mongodbBackend(db, 'acl_', true);
acl = new node_acl(mongoBackend);
});
Я уверен, что база данных подключена, но код, запущенный выше, далмне сообщение об ошибке
_Unhandled rejection TypeError: self.db.collection is not a function
at /Users/abc/Documents/projects/game/server/node_modules/acl/lib/mongodb-backend.js:120:15
at /Users/abc/Documents/projects/game/server/node_modules/async/dist/async.js:3853:24
at replenish (/Users/abc/Documents/projects/game/server/node_modules/async/dist/async.js:946:17)
at /Users/abc/Documents/projects/game/server/node_modules/async/dist/async.js:950:9
at eachOfLimit (/Users/abc/Documents/projects/game/server/node_modules/async/dist/async.js:975:24)
at /Users/abc/Documents/projects/game/server/node_modules/async/dist/async.js:980:16
at parallel (/Users/abc/Documents/projects/game/server/node_modules/async/dist/async.js:3852:5)
at Object.series (/Users/abc/Documents/projects/game/server/node_modules/async/dist/async.js:4708:5)
at MongoDBBackend.end (/Users/abc/Documents/projects/game/server/node_modules/acl/lib/mongodb-backend.js:36:11)
at Acl.allow (/Users/abc/Documents/projects/game/server/node_modules/acl/lib/acl.js:346:26)