sails-hook-sequelize-blueprints
sails-hook-sequelize-blueprints copied to clipboard
TypeError: User.hasOne is not a function
TypeError: User.hasOne is not a function
My code
associations: function () { User .hasOne(Role, {foreignKey: 'id'});
},
where is the mistake ?
It's seems a configuration issue, did you installed the dependencies correctly?
If you mean
$ npm install sails-hook-sequelize --save $ npm install sails-hook-sequelize-blueprints --save $ npm install --save sequelize $ npm install --save pg pg-hstore $ npm install --save continuation-local-storage
Yes are installed!
In controller work but not in associations function
Did you disable the ORM on .sailrc file?
"hooks": {
"blueprints": false,
"orm": false,
"pubsub": false
}
it's still looks a configuration issue or reference error, you sure that you have a User model as User.js?
I can't reproduce it, i suggest you take a look at sampleapp https://github.com/cesardeazevedo/sails-hook-sequelize-blueprints/tree/master/test/fixtures/sampleapp
let me know if you got it.
yes i have everything (.sailrc and User)
TypeError: User.hasOne is not a function at Object.User.associations (/srv/http/myapp/api/models/User.js:137:8) at Hook.setAssociation (/srv/http/myapp/node_modules/sails-hook-sequelize/index.js:76:20) at Hook.bound as setAssociation at /srv/http/myapp/node_modules/sails-hook-sequelize/index.js:43:16 at /srv/http/myapp/node_modules/sails/lib/hooks/moduleloader/index.js:294:18 at /srv/http/myapp/node_modules/sails/lib/hooks/moduleloader/index.js:499:14 at buildDictionary (/srv/http/myapp/node_modules/sails-build-dictionary/index.js:134:9) at Function.module.exports.optional (/srv/http/myapp/node_modules/sails-build-dictionary/index.js:160:9) at /srv/http/myapp/node_modules/sails/lib/hooks/moduleloader/index.js:287:25 at buildDictionary (/srv/http/myapp/node_modules/sails-build-dictionary/index.js:134:9) at Function.module.exports.optional (/srv/http/myapp/node_modules/sails-build-dictionary/index.js:160:9) at Hook.loadModels (/srv/http/myapp/node_modules/sails/lib/hooks/moduleloader/index.js:279:23) at Hook.bound as loadModels at Hook.initialize (/srv/http/myapp/node_modules/sails-hook-sequelize/index.js:26:28) at Hook.bound as initialize at /srv/http/myapp/node_modules/sails/lib/hooks/index.js:75:14 at /srv/http/myapp/node_modules/sails/node_modules/async/lib/async.js:451:17 at /srv/http/myapp/node_modules/sails/node_modules/async/lib/async.js:441:17 at _each (/srv/http/myapp/node_modules/sails/node_modules/async/lib/async.js:46:13) at Immediate.taskComplete (/srv/http/myapp/node_modules/sails/node_modules/async/lib/async.js:440:13) at Immediate._onImmediate (/srv/http/myapp/node_modules/async-listener/glue.js:188:31) at processImmediate as _immediateCallback
can you post your models? i can't reproduce it.
I have the same problem, but all other models works fine, it is just User model.