Last active
August 29, 2015 13:57
-
-
Save noosxe/9460928 to your computer and use it in GitHub Desktop.
Sequelize issue #1414 test case
This file contains hidden or 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
| node_modules/ |
This file contains hidden or 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
| 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(""); | |
| }); |
This file contains hidden or 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
| { | |
| "name": "seq_test", | |
| "version": "0.1.0", | |
| "private": true, | |
| "scripts": { | |
| "start": "node app.js" | |
| }, | |
| "dependencies": { | |
| "mysql": "2.1.0", | |
| "sequelize": "1.7.0" | |
| } | |
| } |
This file contains hidden or 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
| 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