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

Commit b4b0b9b7 by Sascha Depold

Add new methods for and / or queries

1 parent e1d048e2
Showing with 20 additions and 0 deletions
......@@ -422,6 +422,14 @@ module.exports = (function() {
return new Utils.asIs(val)
}
Sequelize.and = Sequelize.prototype.and = function() {
return new Utils.and(Array.prototype.slice.call(arguments))
}
Sequelize.or = Sequelize.prototype.or = function() {
return new Utils.or(Array.prototype.slice.call(arguments))
}
Sequelize.prototype.transaction = function(_options, _callback) {
var options = (typeof _options === 'function') ? {} : _options
, callback = (typeof _options === 'function') ? _options : _callback
......
......@@ -523,6 +523,7 @@ var Utils = module.exports = {
tickChar = tickChar || Utils.TICK_CHAR
return s.replace(new RegExp(tickChar, 'g'), "")
},
/*
* Utility functions for representing SQL functions, and columns that should be escaped.
* Please do not use these functions directly, use Sequelize.fn and Sequelize.col instead.
......@@ -531,13 +532,16 @@ var Utils = module.exports = {
this.fn = fn
this.args = args
},
col: function (col) {
this.col = col
},
cast: function (val, type) {
this.val = val
this.type = (type || '').trim()
},
literal: function (val) {
this.val = val
},
......@@ -546,6 +550,14 @@ var Utils = module.exports = {
this.val = val
},
and: function(args) {
this.args = args
},
or: function(args) {
this.args = args
},
generateUUID: function() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8)
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!