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 27d79f35
authored
Sep 24, 2013
by
Daniel Durante
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added private paranoidClause for DRY.
1 parent
802d4c77
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
28 deletions
lib/dao-factory.js
lib/dao-factory.js
View file @
27d79f3
...
@@ -339,15 +339,7 @@ module.exports = (function() {
...
@@ -339,15 +339,7 @@ module.exports = (function() {
this
.
options
.
whereCollection
=
options
.
where
||
null
this
.
options
.
whereCollection
=
options
.
where
||
null
}
}
if
(
this
.
options
.
paranoid
===
true
)
{
options
=
paranoidClause
.
call
(
this
,
options
)
options
=
options
||
{}
options
.
where
=
options
.
where
||
{}
if
(
typeof
options
.
where
===
"string"
)
{
options
.
where
+=
' AND '
+
this
.
QueryInterface
.
quoteIdentifier
(
this
.
options
.
deletedAt
)
+
' IS NULL '
}
else
{
options
.
where
[
this
.
options
.
deletedAt
]
=
null
}
}
return
this
.
QueryInterface
.
select
(
this
,
this
.
tableName
,
options
,
Utils
.
_
.
defaults
({
return
this
.
QueryInterface
.
select
(
this
,
this
.
tableName
,
options
,
Utils
.
_
.
defaults
({
type
:
'SELECT'
,
type
:
'SELECT'
,
...
@@ -440,16 +432,7 @@ module.exports = (function() {
...
@@ -440,16 +432,7 @@ module.exports = (function() {
}
}
}
}
if
(
this
.
options
.
paranoid
===
true
)
{
options
=
paranoidClause
.
call
(
this
,
options
)
options
=
options
||
{}
options
.
where
=
options
.
where
||
{}
if
(
typeof
options
.
where
===
"string"
)
{
options
.
where
+=
' AND '
+
this
.
QueryInterface
.
quoteIdentifier
(
this
.
options
.
deletedAt
)
+
' IS NULL '
}
else
{
options
.
where
[
this
.
options
.
deletedAt
]
=
null
}
}
options
.
limit
=
1
options
.
limit
=
1
return
this
.
QueryInterface
.
select
(
this
,
this
.
getTableName
(),
options
,
Utils
.
_
.
defaults
({
return
this
.
QueryInterface
.
select
(
this
,
this
.
getTableName
(),
options
,
Utils
.
_
.
defaults
({
...
@@ -464,15 +447,7 @@ module.exports = (function() {
...
@@ -464,15 +447,7 @@ module.exports = (function() {
options
.
attributes
.
push
([
'count(*)'
,
'count'
])
options
.
attributes
.
push
([
'count(*)'
,
'count'
])
options
.
parseInt
=
true
options
.
parseInt
=
true
if
(
this
.
options
.
paranoid
===
true
)
{
options
=
paranoidClause
.
call
(
this
,
options
)
options
=
options
||
{}
options
.
where
=
options
.
where
||
{}
if
(
typeof
options
.
where
===
"string"
)
{
options
.
where
+=
' AND '
+
this
.
QueryInterface
.
quoteIdentifier
(
this
.
options
.
deletedAt
)
+
' IS NULL '
}
else
{
options
.
where
[
this
.
options
.
deletedAt
]
=
null
}
}
return
this
.
QueryInterface
.
rawSelect
(
this
.
getTableName
(),
options
,
'count'
)
return
this
.
QueryInterface
.
rawSelect
(
this
.
getTableName
(),
options
,
'count'
)
}
}
...
@@ -727,6 +702,29 @@ module.exports = (function() {
...
@@ -727,6 +702,29 @@ module.exports = (function() {
// private
// private
var
paranoidClause
=
function
(
options
)
{
if
(
this
.
options
.
paranoid
===
true
)
{
options
=
options
||
{}
options
.
where
=
options
.
where
||
{}
// Don't overwrite our explicit deletedAt search value if we provide one
if
(
!!
options
.
where
[
this
.
options
.
deletedAt
])
{
return
options
}
if
(
typeof
options
.
where
===
"string"
)
{
options
.
where
+=
' AND '
+
this
.
QueryInterface
.
quoteIdentifier
(
this
.
options
.
deletedAt
)
+
' IS NULL '
}
else
if
(
Array
.
isArray
(
options
.
where
))
{
options
.
where
[
0
]
+=
' AND '
+
this
.
QueryInterface
.
quoteIdentifier
(
this
.
options
.
deletedAt
)
+
' IS NULL '
}
else
{
options
.
where
[
this
.
options
.
deletedAt
]
=
null
}
}
return
options
}
var
addOptionalClassMethods
=
function
()
{
var
addOptionalClassMethods
=
function
()
{
var
self
=
this
var
self
=
this
Utils
.
_
.
each
(
this
.
options
.
classMethods
||
{},
function
(
fct
,
name
)
{
self
[
name
]
=
fct
})
Utils
.
_
.
each
(
this
.
options
.
classMethods
||
{},
function
(
fct
,
name
)
{
self
[
name
]
=
fct
})
...
...
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