Created
October 3, 2013 10:27
-
-
Save FredrikAppelros/6807906 to your computer and use it in GitHub Desktop.
sequelize validation problem
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sequelize = require 'sequelize' | |
sequelize = new Sequelize 'sequelize-test', 'postgres', 'changeme123', | |
host: 'localhost' | |
port: 5432 | |
dialect: 'postgres' | |
A = sequelize.define 'a', name: Sequelize.STRING | |
B = sequelize.define 'b', | |
name: | |
type: Sequelize.STRING | |
validate: | |
notEmpty: true | |
A.hasMany B | |
sequelize.sync().success -> | |
chainer = new Sequelize.Utils.QueryChainer [ | |
A.create name: 'a' | |
B.create name: 'b' | |
] | |
chainer.run().success (res, a, b) -> | |
console.log a.dataValues | |
console.log b.dataValues | |
a.setBs([b]).success(-> | |
a.getBs().success (bs) -> | |
console.log bs.map (i) -> i.dataValues | |
).error (err) -> | |
console.log err |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment