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

Commit eeb453df by Sascha Depold

just reverted getter idea for save, drop, etc.

1 parent 78d1f617
......@@ -34,15 +34,15 @@ ModelDefinition.prototype.sync = function(options) {
.on('failure', function() { self.emit('failure', self) })
}
if(options.force) this.drop.on('success', function() { doQuery() })
if(options.force) this.drop().on('success', function() { doQuery() })
else doQuery()
return this
}
ModelDefinition.prototype.__defineGetter__('drop', function() {
ModelDefinition.prototype.drop = function() {
return this.query(QueryGenerator.dropTableQuery(this.tableName, this.id))
})
}
ModelDefinition.prototype.__defineGetter__('all', function() {
return this.query(QueryGenerator.selectQuery(this.tableName))
......
......@@ -36,16 +36,16 @@ Model.prototype.query = function() {
return s.query.apply(s, args)
}
Model.prototype.__defineGetter__('save', function() {
Model.prototype.save = function() {
if(this.isNewRecord)
return this.query(QueryGenerator.insertQuery(this.definition.tableName, this.values))
else
return this.query(QueryGenerator.updateQuery(this.definition.tableName, this.values, this.id))
})
}
Model.prototype.__defineGetter__('destroy', function() {
Model.prototype.destroy = function() {
return this.query(QueryGenerator.deleteQuery(this.definition.tableName, this.id))
})
}
Model.prototype.__defineGetter__('isNewRecord', function() {
return this.id == null
......
......@@ -18,5 +18,12 @@ module.exports = {
bio: Sequelize.TEXT
})
User.sync().on('failure', beforeExit)
},
'drop should work': function(beforeExit) {
var User = sequelize.define('User', {
name: Sequelize.STRING,
bio: Sequelize.TEXT
})
User.drop().on('success', beforeExit)
}
}
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!