Mongodb client isConnected property is deprecated
JinYuSha0 opened this issue · 6 comments
JinYuSha0 commented
see mongodb/node-mongodb-native@5a37a92
and then will throw error: Casbin mongo adapter not connected
if (this.mongoClient.isConnected === undefined) {
throw new Error('Casbin mongo adapter not connected');
}
JinYuSha0 commented
That's how I solved it for now
async function loadEnforcer() {
const model = path.resolve(__dirname, "../config/rbac_model.conf");
const adapter = await MongoAdapter.newAdapter({
uri: process.env.DATABASE_URL,
option: {
useNewUrlParser: true,
},
database: process.env.DATABASE_NAME,
collection: "casbin",
});
await adapter.mongoClient.connect();
const e = new Enforcer();
await e.initWithAdapter(model, adapter, true);
adapter.mongoClient.isConnected = true;
await e.loadPolicy();
return e;
}
hsluoyz commented
@JinYuSha0 can you make a PR to fix it?
hsluoyz commented
JinYuSha0 commented
@JinYuSha0 can you make a PR to fix it?
I can offer a PR as early as tomorrow
juicycleff commented
Updating this package soon
juicycleff commented
anyone wants to be added as a contributor please let me know