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

Commit 5817c532 by Sascha Depold

added error handling to examples

1 parent 90bfe09b
...@@ -30,15 +30,19 @@ var task1 = new Task({ ...@@ -30,15 +30,19 @@ var task1 = new Task({
name: 'Choose a nice MySQL connector', name: 'Choose a nice MySQL connector',
deadline: new Date(Date.parse("Jul 8, 2100")), deadline: new Date(Date.parse("Jul 8, 2100")),
importance: 10 importance: 10
}) }),
var task2 = new Task({ task2 = new Task({
name: 'Build the rest', name: 'Build the rest',
deadline: new Date(Date.parse("Jul 8, 2005")), deadline: new Date(Date.parse("Jul 8, 2005")),
importance: 90 importance: 90
}) })
Task.drop(function(table, error) {
if(error) return Sequelize.Helper.log(error)
Task.sync(function(table, error) {
if(error) return Sequelize.Helper.log(error)
Task.drop(function() {
Task.sync(function() {
task1.save(function() { task1.save(function() {
task2.save(function() { task2.save(function() {
......
...@@ -6,8 +6,12 @@ var Sequelize = require(__dirname + "/../../src/Sequelize").Sequelize, ...@@ -6,8 +6,12 @@ var Sequelize = require(__dirname + "/../../src/Sequelize").Sequelize,
Project.hasMany('tasks', Task) Project.hasMany('tasks', Task)
Task.belongsTo('project', Project) Task.belongsTo('project', Project)
sequelize.drop(function() { sequelize.drop(function(errors) {
sequelize.sync(function() { if(errors.length > 0) return Sequelize.Helper.log(errors)
sequelize.sync(function(errors) {
if(errors.length > 0) return Sequelize.Helper.log(errors)
new Project({ new Project({
name: 'Sequelize', name: 'Sequelize',
description: 'A nice MySQL ORM for NodeJS' 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!