Open ErikvdVen opened 8 years ago
@jonmassot Already read the thread, tried it (as you might see at my code), but it does not work. Solution of valmy's is not implemented in the latest version, so I cannot use the MongooseBackend. But the solution of DesignByOnyx does not work.
Just tried this as well:
import Acl from 'acl';
import Mongoose from 'mongoose';
var dbc = Mongoose.connect('mongodb://127.0.0.1:27017/acl', {});
let acl = new Acl(new Acl.mongodbBackend(dbc.connection.db));
If I use a very similar code but with Mongodb, it does work. But we prefer Mongoose, so would be great if there's a solution :) :)
My bad, I did answer quickly without taking the time to wrote a more elaborate answer!
My intention was to point out the adapter @valmy wrote that could be adapted to an external adapter, like knex. or you can try to fork latest acl
and merge mongoose_backend
in it, but I'm pretty sure it won't get merged, since mongoose is an ODM on top of mongoDB.
Thank you for your answer. So far I'm already trying to implement the mongoose-backend in the latest version again. It seems that it does work, more or less. It does create a collection called "acls" and it does contain the rules (meta), parents and paths. But still testing ;)
:+1:
Aargh, de connection was still closed -_-. So Mongoose does work, only the connection wasn't open yet, before passing the mongoose.connection.db
variable.
So the bug was somewhere else in the application. It didn't give any errors (even all other tables for the application were created), so it seemed the connection was just fine...
We found out the connection was the issue, by logging console.log(mongoose.connection._hasOpened);
and this returned a false. After fixing this issue everything works fine!
You can close this issue now :+1:
I had the same issue, just for anyone else with this issue you can put your code inside:
mongoose.connection.on('connected', function () {
// ACL code here
});
And it then it works OK.
Mongoose does not seem to work with the mongodbBackend. We use
mongoose version 4.1.7
. It doesn't give any errors, but it doesn't create any collections either! I spent hours to figure out what could be the problem. But it seems that mongoose simply does not work with the mongodbBackend.This is my Mongoose code (the mongoose variable just contains the mongoose connection). I also checked the
mongoose.connection.db
variable, and it contains the right values. After all, no connection failure so... And it does create the database and every other collection locally for the application (after removing the local database and restarting the application) except for the ACL collections.Mongoose:
Just to make sure there's nothing else which could cause the problem, I replaced mongoose with just mongodb (we use mongoose in the rest of our application, so we would love to use mongoose instead).
And this code does work (meta, parents and resources collections were created after running below mentioned code):
MongoDB: