Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
public
/
sequelize
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
不要怂,就是干,撸起袖子干!
Commit b4b0b9b7
authored
Jan 24, 2014
by
Sascha Depold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add new methods for and / or queries
1 parent
e1d048e2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
0 deletions
lib/sequelize.js
lib/utils.js
lib/sequelize.js
View file @
b4b0b9b
...
@@ -422,6 +422,14 @@ module.exports = (function() {
...
@@ -422,6 +422,14 @@ module.exports = (function() {
return
new
Utils
.
asIs
(
val
)
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
)
{
Sequelize
.
prototype
.
transaction
=
function
(
_options
,
_callback
)
{
var
options
=
(
typeof
_options
===
'function'
)
?
{}
:
_options
var
options
=
(
typeof
_options
===
'function'
)
?
{}
:
_options
,
callback
=
(
typeof
_options
===
'function'
)
?
_options
:
_callback
,
callback
=
(
typeof
_options
===
'function'
)
?
_options
:
_callback
...
...
lib/utils.js
View file @
b4b0b9b
...
@@ -523,6 +523,7 @@ var Utils = module.exports = {
...
@@ -523,6 +523,7 @@ var Utils = module.exports = {
tickChar
=
tickChar
||
Utils
.
TICK_CHAR
tickChar
=
tickChar
||
Utils
.
TICK_CHAR
return
s
.
replace
(
new
RegExp
(
tickChar
,
'g'
),
""
)
return
s
.
replace
(
new
RegExp
(
tickChar
,
'g'
),
""
)
},
},
/*
/*
* Utility functions for representing SQL functions, and columns that should be escaped.
* 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.
* Please do not use these functions directly, use Sequelize.fn and Sequelize.col instead.
...
@@ -531,13 +532,16 @@ var Utils = module.exports = {
...
@@ -531,13 +532,16 @@ var Utils = module.exports = {
this
.
fn
=
fn
this
.
fn
=
fn
this
.
args
=
args
this
.
args
=
args
},
},
col
:
function
(
col
)
{
col
:
function
(
col
)
{
this
.
col
=
col
this
.
col
=
col
},
},
cast
:
function
(
val
,
type
)
{
cast
:
function
(
val
,
type
)
{
this
.
val
=
val
this
.
val
=
val
this
.
type
=
(
type
||
''
).
trim
()
this
.
type
=
(
type
||
''
).
trim
()
},
},
literal
:
function
(
val
)
{
literal
:
function
(
val
)
{
this
.
val
=
val
this
.
val
=
val
},
},
...
@@ -546,6 +550,14 @@ var Utils = module.exports = {
...
@@ -546,6 +550,14 @@ var Utils = module.exports = {
this
.
val
=
val
this
.
val
=
val
},
},
and
:
function
(
args
)
{
this
.
args
=
args
},
or
:
function
(
args
)
{
this
.
args
=
args
},
generateUUID
:
function
()
{
generateUUID
:
function
()
{
return
'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'
.
replace
(
/
[
xy
]
/g
,
function
(
c
)
{
return
'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'
.
replace
(
/
[
xy
]
/g
,
function
(
c
)
{
var
r
=
Math
.
random
()
*
16
|
0
,
v
=
c
==
'x'
?
r
:
(
r
&
0x3
|
0x8
)
var
r
=
Math
.
random
()
*
16
|
0
,
v
=
c
==
'x'
?
r
:
(
r
&
0x3
|
0x8
)
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment