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

Commit b95a0456 by Sascha Depold

use the new query interface for creating the tables when syncing

1 parent 766f5ea1
Showing with 13 additions and 12 deletions
......@@ -35,27 +35,28 @@ module.exports = (function() {
return this.modelManager.sequelize.connectorManager.getQueryGenerator()
})
ModelFactory.prototype.__defineGetter__('QueryInterface', function() {
return this.modelManager.sequelize.getQueryInterface()
})
ModelFactory.prototype.sync = function(options) {
options = Utils.merge(options || {}, this.options)
var self = this
var eventEmitter = new Utils.CustomEventEmitter(function() {
return new Utils.CustomEventEmitter(function(emitter) {
var doQuery = function() {
query.call(self, self.QueryGenerator.createTableQuery(self.tableName, self.attributes, options))
.success(function() { eventEmitter.emit('success', self) })
.error(function(err) { eventEmitter.emit('failure', err) })
self.QueryInterface
.createTable(self.tableName, self.attributes, options)
.success(function() { emitter.emit('success', self) })
.error(function(err) { emitter.emit('failure', err) })
}
if(options.force) {
self.drop()
.success(function() { doQuery() })
.error(function(err) { eventEmitter.emit('failure', err) })
} else {
if(options.force)
self.drop().success(doQuery).error(function(err) { emitter.emit('failure', err) })
else
doQuery()
}
})
return eventEmitter.run()
}).run()
}
ModelFactory.prototype.drop = function() {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!