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

Commit 766f5ea1 by Sascha Depold

query interface for high-level-access to sql functions

1 parent d590fe20
Showing with 61 additions and 1 deletions
var Utils = require("./utils") var Utils = require("./utils")
, Mixin = require("./associations/mixin") , Mixin = require("./associations/mixin")
, Validator = require("validator") , Validator = require("validator")
, QueryInterface = require("./query-interface")
module.exports = (function() { module.exports = (function() {
var Model = function(values, options) { var Model = function(values, options) {
...@@ -30,12 +31,16 @@ module.exports = (function() { ...@@ -30,12 +31,16 @@ module.exports = (function() {
return this.__definition.QueryGenerator return this.__definition.QueryGenerator
}) })
Model.prototype.getQueryInterface = function() {
var sequelize = this.__definition.modelManager.sequelize
return this.queryInterface = this.queryInterface || new QueryInterface(sequelize)
}
Model.prototype.save = function() { Model.prototype.save = function() {
var attr = this.__options.underscored ? 'updated_at' : 'updatedAt' var attr = this.__options.underscored ? 'updated_at' : 'updatedAt'
if(this.hasOwnProperty(attr)) if(this.hasOwnProperty(attr))
this[attr] = new Date() this[attr] = new Date()
if(this.isNewRecord) { if(this.isNewRecord) {
var self = this var self = this
var eventEmitter = new Utils.CustomEventEmitter(function() { var eventEmitter = new Utils.CustomEventEmitter(function() {
......
module.exports = (function() {
var QueryInterface = function(sequelize) {
this.sequelize = sequelize
}
QueryInterface.prototype.createTable = function() {
}
QueryInterface.prototype.dropTable = function() {
}
QueryInterface.prototype.renameTable = function() {
}
QueryInterface.prototype.addColumn = function() {
}
QueryInterface.prototype.removeColumn = function() {
}
QueryInterface.prototype.changeColumn = function() {
}
QueryInterface.prototype.renameColumn = function() {
}
QueryInterface.prototype.addIndex = function() {
}
QueryInterface.prototype.removeIndex = function() {
}
QueryInterface.prototype.insert = function() {
}
QueryInterface.prototype.update = function() {
}
QueryInterface.prototype.destroy = function() {
}
return QueryInterface
})()
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!