不要怂,就是干,撸起袖子干!

Commit 5817c532 by Sascha Depold

added error handling to examples

1 parent 90bfe09b
......@@ -27,18 +27,22 @@ var Task = sequelize.define("Task", {
// instance creation
var task1 = new Task({
name: 'Choose a nice MySQL connector',
deadline: new Date(Date.parse("Jul 8, 2100")),
importance: 10
})
var task2 = new Task({
name: 'Build the rest',
deadline: new Date(Date.parse("Jul 8, 2005")),
importance: 90
})
name: 'Choose a nice MySQL connector',
deadline: new Date(Date.parse("Jul 8, 2100")),
importance: 10
}),
task2 = new Task({
name: 'Build the rest',
deadline: new Date(Date.parse("Jul 8, 2005")),
importance: 90
})
Task.drop(function(table, error) {
if(error) return Sequelize.Helper.log(error)
Task.drop(function() {
Task.sync(function() {
Task.sync(function(table, error) {
if(error) return Sequelize.Helper.log(error)
task1.save(function() {
task2.save(function() {
......
......@@ -6,8 +6,12 @@ var Sequelize = require(__dirname + "/../../src/Sequelize").Sequelize,
Project.hasMany('tasks', Task)
Task.belongsTo('project', Project)
sequelize.drop(function() {
sequelize.sync(function() {
sequelize.drop(function(errors) {
if(errors.length > 0) return Sequelize.Helper.log(errors)
sequelize.sync(function(errors) {
if(errors.length > 0) return Sequelize.Helper.log(errors)
new Project({
name: 'Sequelize',
description: 'A nice MySQL ORM for NodeJS'
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!