yonjah / node_acl_sequelize

Node Acl Sequelize Backend
MIT License
44 stars 20 forks source link

this module is not respecting the table schema for creating the acl tables #6

Closed shemna closed 7 years ago

shemna commented 7 years ago

I supposed that the following code should create the acl tables in 'test' schema, instead generated in public schema var Acl = require('acl'); var Sequelize = require('sequelize'); var AclSeq = require('acl-sequelize'); var db = new Sequelize( 'acl', 'postgres', 'postgres', { schema: 'test', dialectOptions: { searchPath: 'test', prependSearchPath: true }, host: 'localhost', port: 5432, dialect: 'postgres' });

var abcacl = new Acl(new AclSeq(db, { prefix: 'acl' }));

I dig bit mmore on teh code, an i see that line 30 of lib/dbTasks.js should be passed with db.options.

here is the modified line db.define(name, schema[table] || defaultSchema, db.options).sync();

yonjah commented 7 years ago

I don't have experience with Postgres but from sequelize docs -> http://docs.sequelizejs.com/en/latest/api/sequelize/#definemodelname-attributes-options-model The options passed to the define method are any merged with options.defined passed to the constructor so if I undestand what you are trying to do you need to call the constructor like this

    var db = new Sequelize( 'acl', 'postgres', 'postgres', {
        schema: 'test',
        define: {
            schema: 'test'
        },
        dialectOptions: {
            searchPath: 'test',
            prependSearchPath: true
        },
        host: 'localhost',
        port: 5432,
        dialect: 'postgres'
    });
shemna commented 7 years ago

Thanks alot. Thant worked