carlos8f / node-relations

Entity relationship, role, and permissions API for Node.js
61 stars 20 forks source link

subject role map request issues with redis? #11

Open rssk opened 8 years ago

rssk commented 8 years ago

First off, awesome module! I think I'm running into some issues when I'm grabbing subject role mappings w/ this example code:

var relations = require('relations');
var redis = require('redis');

client = redis.createClient();

relations.use(relations.stores.redis, {client: client});
relations.define('repo', {
  owner: ['pull', 'push', 'administrate'],
  collaborator: ['pull', 'push']
});

relations.repo('%s is the owner of %s', 'ross', 'testrepo');
relations.repo('%s is the collaborator of %s', 'ross', 'testrepo');
relations.repo('explain who can act on testrepo', function(err, res) {
    console.log(res);
});

which gives

test$ node index.js 
{ testrepo: [ 'collaborator', 'owner' ] }

Which seems to have the object as the subject?

In the redis tests I see prefix has a : in the prefix name (https://github.com/carlos8f/node-relations/blob/master/test/basic.js#L12) and they seem to be parsed that way as well (https://github.com/carlos8f/node-relations/blob/master/stores/redis.js#L212). Should prefixes contain colons?

Thanks!

tao commented 7 years ago

I get this issue to, adding a colon to the redis prefix fixes the problem for now.