Skip to content

self.db.collection is not a function #281

Description

@helxsz

i am using ACL module with mongodb, i define some roles and their permissions using the acl.allow() function.

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);
});

I am sure the database is connected, but the code running above gave me an error saying

_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)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions