Skip to content

Instantly share code, notes, and snippets.

@noosxe
Last active August 29, 2015 13:57
Show Gist options
  • Save noosxe/9460928 to your computer and use it in GitHub Desktop.
Save noosxe/9460928 to your computer and use it in GitHub Desktop.
Sequelize issue #1414 test case
node_modules/
var S = require("sequelize");
var s = global.s = new S("seq", "root", "",
{ host: 'localhost',
port: 3306,
dialect: 'mysql',
logging: console.log,
omitNull: true
}, { insecureAuth: true });
global.m = {};
var section = global.m.section = s.define('section', { name: S.STRING });
var layout = global.m.layout = s.define('layout', { name: S.STRING });
section.belongsTo(layout, {
as: layout.name,
foreignKey: layout.name,
foreignKeyConstraint: true
});
s.sync().success(function() {
console.log("synced");
require('./run');
}).error(function(error) {
console.log("");
console.log("database synchronization failed!");
console.log(error);
console.log("");
});
{
"name": "seq_test",
"version": "0.1.0",
"private": true,
"scripts": {
"start": "node app.js"
},
"dependencies": {
"mysql": "2.1.0",
"sequelize": "1.7.0"
}
}
console.log("running");
m.section.create({ name: 'test1' }).success(function() {
m.section.find({ where: { name: 'test1' }, include: [{ model: m.layout, as: 'layout'}] }).success(function(result) {
console.log(result);
}).error(function(err) {
console.log(err);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment