Answer the question
In order to leave comments, you need to log in
How to export an ACL module?
I have been suffering for 2 days with the export of the ACL module , the search engine is silent in solving these problems. There are similar topics on other forums, but no solution has been found, although I'm sure it's possible!
Essence of the question:
According to the ACL instruction, it needs to be initialized inside mongoose.conect:
const mongoose = require('mongoose');
var node_acl = require('acl');
exports.connect = function (done) {
mongoose.connect(url, {useCreateIndex: true, useNewUrlParser: true}, function (err, db) {
if (err) {
console.log('Ошибка запуска базы')
return done(err);
}
var acl = new node_acl( new node_acl.mongodbBackend(mongoose.connection.db, 'acl_') );
console.log('Подключились к базе данных');
done();
});
};
exports.connect = function (done) {
mongoose.connect(url, {useCreateIndex: true, useNewUrlParser: true}, function (err, db) {
if (err) {
console.log('Ошибка запуска базы')
return done(err);
}
var acl = new node_acl( new node_acl.mongodbBackend(mongoose.connection.db, 'acl_') );
console.log('Подключились к базе данных');
done();
});
};
var conn = mongoose.connection;
var acl = new node_acl( new node_acl.mongodbBackend(conn.db, 'acl_') );
Wrap acl in a function if you are calling the poll results or wrap the connection in a Promise that is exported
Answer the question
In order to leave comments, you need to log in
module.exports = new Promise( (resolve, reject) => {
mongoose.connect(url, {useCreateIndex: true, useNewUrlParser: true}, function (err, db) {
var acl = new node_acl(new node_acl.mongodbBackend(mongoose.connection.db, 'acl_'));
resolve(acl);
});
})
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question