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

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() { ...@@ -35,27 +35,28 @@ module.exports = (function() {
return this.modelManager.sequelize.connectorManager.getQueryGenerator() return this.modelManager.sequelize.connectorManager.getQueryGenerator()
}) })
ModelFactory.prototype.__defineGetter__('QueryInterface', function() {
return this.modelManager.sequelize.getQueryInterface()
})
ModelFactory.prototype.sync = function(options) { ModelFactory.prototype.sync = function(options) {
options = Utils.merge(options || {}, this.options) options = Utils.merge(options || {}, this.options)
var self = this var self = this
var eventEmitter = new Utils.CustomEventEmitter(function() { return new Utils.CustomEventEmitter(function(emitter) {
var doQuery = function() { var doQuery = function() {
query.call(self, self.QueryGenerator.createTableQuery(self.tableName, self.attributes, options)) self.QueryInterface
.success(function() { eventEmitter.emit('success', self) }) .createTable(self.tableName, self.attributes, options)
.error(function(err) { eventEmitter.emit('failure', err) }) .success(function() { emitter.emit('success', self) })
.error(function(err) { emitter.emit('failure', err) })
} }
if(options.force) { if(options.force)
self.drop() self.drop().success(doQuery).error(function(err) { emitter.emit('failure', err) })
.success(function() { doQuery() }) else
.error(function(err) { eventEmitter.emit('failure', err) })
} else {
doQuery() doQuery()
}
})
return eventEmitter.run() }).run()
} }
ModelFactory.prototype.drop = function() { 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!