dtoubelis / sails-cassandra

Cassanda database adapter for Sails.js
MIT License
26 stars 11 forks source link

Error working with Waterline #28

Closed karthikshanmugam closed 9 years ago

karthikshanmugam commented 9 years ago

Hi,

I was just switching from sails-redis to sails-cassandra, but stumped with this error. Can you please help?

TypeError: Cannot read property 'collections' of undefined at setModel (/home/ubuntu/nodejs/t4h_auth_good/node_modules/openid-connect/node_modules/modelling/index.js:209:30) at procModels (/home/ubuntu/nodejs/t4h_auth_good/node_modules/openid-connect/node_modules/modelling/index.js:200:7) at /home/ubuntu/nodejs/t4h_auth_good/node_modules/openid-connect/node_modules/modelling/index.js:223:6 at Layer.handle as handle_request at next (/home/ubuntu/nodejs/t4h_auth_good/node_modules/express/lib/router/route.js:131:13) at Route.dispatch (/home/ubuntu/nodejs/t4h_auth_good/node_modules/express/lib/router/route.js:112:3) at Layer.handle as handle_request at /home/ubuntu/nodejs/t4h_auth_good/node_modules/express/lib/router/index.js:277:22 at Function.process_params (/home/ubuntu/nodejs/t4h_auth_good/node_modules/express/lib/router/index.js:330:12) at next (/home/ubuntu/nodejs/t4h_auth_good/node_modules/express/lib/router/index.js:271:10) at serveStatic (/home/ubuntu/nodejs/t4h_auth_good/node_modules/express/node_modules/serve-static/index.js:74:16) at Layer.handle as handle_request at trim_prefix (/home/ubuntu/nodejs/t4h_auth_good/node_modules/express/lib/router/index.js:312:13) at /home/ubuntu/nodejs/t4h_auth_good/node_modules/express/lib/router/index.js:280:7 at Function.process_params (/home/ubuntu/nodejs/t4h_auth_good/node_modules/express/lib/router/index.js:330:12) at next (/home/ubuntu/nodejs/t4h_auth_good/node_modules/express/lib/router/index.js:271:10)

Best regards, Karthik

dtoubelis commented 9 years ago

I see no reference to sails-cassandra adapter here. Could you provide more details?

karthikshanmugam commented 9 years ago

Hi,

This is when I'm using the openid-connect node module to implement OpenID Provider service. By default, it is configured to use redis as the storage driver. I'm trying to use cassandra instead of redis.

You can see the source file for the openid-connect here https://github.com/agmoyano/OpenIDConnect/blob/master/index.js

I have modified the below sections to use sails-cassandra instead of sails-redis

    adapters: {
        redis: sailsRedis,
        cassandra: require('sails-cassandra')
    },
    connections: {
        def: {
            adapter: 'redis'
        },
        cas: {
            adapter: 'cassandra'
            contactPoints: [<ip address of cassasandra cluster>],
            keyspace: 'openid_auth_db'
        }
    },

In the models, I have changes the connections from 'def' to 'cas' to switch from redis to cassandra. With redis, it works fine, but with cassandra it throws the above error. It create the necessary tables in the database, so, I don't think connection is the problem here.

Best regards, Karthik

karthikshanmugam commented 9 years ago

Hi,

Some new update. It seems in one of the models, the attribute name was "token" which is a reserved keyword in CQLSH. Hence the failure.

Thanks for your help.

Best regards, Karthik

dtoubelis commented 9 years ago

Thanks for the update. I added escaping of column names to the adapter code and pushed v0.10.10 to the npm repository. Please give it a try and let me know if it addresses the issue.

dtoubelis commented 9 years ago

@karthikshanmugam, Haven't heard back from you, so I consider it closed. Thanks for the bug report.