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 046fa0b1
authored
Oct 30, 2012
by
Mick Hansen
Committed by
Jan Aagaard Meier
Oct 30, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
im not very good at cherry-picking
1 parent
002b1fa0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
1 deletions
lib/dao-factory.js
lib/query-interface.js
lib/dao-factory.js
View file @
046fa0b
...
@@ -2,6 +2,8 @@ var Utils = require("./utils")
...
@@ -2,6 +2,8 @@ var Utils = require("./utils")
,
DAO
=
require
(
"./dao"
)
,
DAO
=
require
(
"./dao"
)
,
DataTypes
=
require
(
"./data-types"
)
,
DataTypes
=
require
(
"./data-types"
)
var
tk
=
require
(
'timekit'
);
module
.
exports
=
(
function
()
{
module
.
exports
=
(
function
()
{
var
DAOFactory
=
function
(
name
,
attributes
,
options
)
{
var
DAOFactory
=
function
(
name
,
attributes
,
options
)
{
var
self
=
this
var
self
=
this
...
@@ -112,6 +114,7 @@ module.exports = (function() {
...
@@ -112,6 +114,7 @@ module.exports = (function() {
}
}
DAOFactory
.
prototype
.
find
=
function
(
options
)
{
DAOFactory
.
prototype
.
find
=
function
(
options
)
{
var
start
=
tk
.
time
();
// no options defined?
// no options defined?
// return an emitter which emits null
// return an emitter which emits null
if
([
null
,
undefined
].
indexOf
(
options
)
>
-
1
)
{
if
([
null
,
undefined
].
indexOf
(
options
)
>
-
1
)
{
...
@@ -145,6 +148,7 @@ module.exports = (function() {
...
@@ -145,6 +148,7 @@ module.exports = (function() {
options
.
limit
=
1
options
.
limit
=
1
this
.
daoFactoryManager
.
sequelize
.
_metric
(
'Model.find'
,
tk
.
time
()
-
start
);
return
this
.
QueryInterface
.
select
(
this
,
this
.
tableName
,
options
,
{
plain
:
true
})
return
this
.
QueryInterface
.
select
(
this
,
this
.
tableName
,
options
,
{
plain
:
true
})
}
}
...
@@ -171,7 +175,7 @@ module.exports = (function() {
...
@@ -171,7 +175,7 @@ module.exports = (function() {
return
this
.
QueryInterface
.
rawSelect
(
this
.
tableName
,
options
,
'min'
)
return
this
.
QueryInterface
.
rawSelect
(
this
.
tableName
,
options
,
'min'
)
}
}
var
tk
=
require
(
'timekit'
);
DAOFactory
.
prototype
.
build
=
function
(
values
,
options
)
{
DAOFactory
.
prototype
.
build
=
function
(
values
,
options
)
{
var
start
=
tk
.
time
();
var
start
=
tk
.
time
();
var
instance
=
new
DAO
(
values
,
Utils
.
_
.
extend
(
this
.
options
,
this
.
attributes
,
{
hasPrimaryKeys
:
this
.
hasPrimaryKeys
}))
var
instance
=
new
DAO
(
values
,
Utils
.
_
.
extend
(
this
.
options
,
this
.
attributes
,
{
hasPrimaryKeys
:
this
.
hasPrimaryKeys
}))
...
...
lib/query-interface.js
View file @
046fa0b
var
Utils
=
require
(
'./utils'
)
var
Utils
=
require
(
'./utils'
)
,
DataTypes
=
require
(
'./data-types'
)
,
DataTypes
=
require
(
'./data-types'
)
var
tk
=
require
(
'timekit'
);
module
.
exports
=
(
function
()
{
module
.
exports
=
(
function
()
{
var
QueryInterface
=
function
(
sequelize
)
{
var
QueryInterface
=
function
(
sequelize
)
{
this
.
sequelize
=
sequelize
this
.
sequelize
=
sequelize
...
@@ -195,7 +197,17 @@ module.exports = (function() {
...
@@ -195,7 +197,17 @@ module.exports = (function() {
}
}
QueryInterface
.
prototype
.
select
=
function
(
factory
,
tableName
,
options
,
queryOptions
)
{
QueryInterface
.
prototype
.
select
=
function
(
factory
,
tableName
,
options
,
queryOptions
)
{
var
start
=
tk
.
time
();
// Not pretty, but a lot of convenience because you dont have to wrap everything!
if
(
options
&&
!
Utils
.
_
.
isEmpty
(
options
)
&&
!
options
.
hasOwnProperty
(
'order'
)
&&
!
options
.
hasOwnProperty
(
'group'
)
&&
!
options
.
hasOwnProperty
(
'limit'
))
{
if
(
!
options
.
hasOwnProperty
(
'where'
))
{
options
=
{
where
:
options
};
}
else
{
if
(
Utils
.
_
.
isEmpty
(
options
.
where
))
options
=
{};
}
}
var
sql
=
this
.
QueryGenerator
.
selectQuery
(
tableName
,
options
)
var
sql
=
this
.
QueryGenerator
.
selectQuery
(
tableName
,
options
)
this
.
sequelize
.
_metric
(
'QueryInterface.select'
,
tk
.
time
()
-
start
);
return
queryAndEmit
.
call
(
this
,
[
sql
,
factory
,
queryOptions
],
'select'
)
return
queryAndEmit
.
call
(
this
,
[
sql
,
factory
,
queryOptions
],
'select'
)
}
}
...
...
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