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 7ce71c63
authored
Oct 30, 2012
by
Jan Aagaard Meier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
removed timing
1 parent
1f391775
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
9 additions
and
48 deletions
lib/dao-factory.js
lib/dao.js
lib/dialects/abstract/query.js
lib/dialects/mysql/query.js
lib/query-interface.js
lib/sequelize.js
lib/dao-factory.js
View file @
7ce71c6
...
@@ -2,8 +2,6 @@ var Utils = require("./utils")
...
@@ -2,8 +2,6 @@ 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
...
@@ -92,7 +90,6 @@ module.exports = (function() {
...
@@ -92,7 +90,6 @@ module.exports = (function() {
}
}
DAOFactory
.
prototype
.
findAll
=
function
(
options
)
{
DAOFactory
.
prototype
.
findAll
=
function
(
options
)
{
var
start
=
tk
.
time
();
var
hasJoin
=
false
;
var
hasJoin
=
false
;
if
((
typeof
options
===
'object'
)
&&
(
options
.
hasOwnProperty
(
'include'
)))
{
if
((
typeof
options
===
'object'
)
&&
(
options
.
hasOwnProperty
(
'include'
)))
{
...
@@ -106,7 +103,6 @@ module.exports = (function() {
...
@@ -106,7 +103,6 @@ module.exports = (function() {
}.
bind
(
this
))
}.
bind
(
this
))
}
}
this
.
daoFactoryManager
.
sequelize
.
_metric
(
'DAOFactory.findAll'
,
tk
.
time
()
-
start
);
return
this
.
QueryInterface
.
select
(
this
,
this
.
tableName
,
options
,
{
type
:
'SELECT'
,
hasJoin
:
hasJoin
})
return
this
.
QueryInterface
.
select
(
this
,
this
.
tableName
,
options
,
{
type
:
'SELECT'
,
hasJoin
:
hasJoin
})
}
}
...
@@ -119,8 +115,6 @@ module.exports = (function() {
...
@@ -119,8 +115,6 @@ module.exports = (function() {
}
}
DAOFactory
.
prototype
.
find
=
function
(
options
)
{
DAOFactory
.
prototype
.
find
=
function
(
options
)
{
var
start
=
tk
.
time
();
var
hasJoin
=
false
;
var
hasJoin
=
false
;
// no options defined?
// no options defined?
// return an emitter which emits null
// return an emitter which emits null
...
@@ -159,7 +153,6 @@ module.exports = (function() {
...
@@ -159,7 +153,6 @@ module.exports = (function() {
options
.
limit
=
1
options
.
limit
=
1
this
.
daoFactoryManager
.
sequelize
.
_metric
(
'DAOFactory.find'
,
tk
.
time
()
-
start
);
return
this
.
QueryInterface
.
select
(
this
,
this
.
tableName
,
options
,
{
plain
:
true
,
type
:
'SELECT'
,
hasJoin
:
hasJoin
})
return
this
.
QueryInterface
.
select
(
this
,
this
.
tableName
,
options
,
{
plain
:
true
,
type
:
'SELECT'
,
hasJoin
:
hasJoin
})
}
}
...
@@ -187,10 +180,8 @@ module.exports = (function() {
...
@@ -187,10 +180,8 @@ module.exports = (function() {
}
}
DAOFactory
.
prototype
.
build
=
function
(
values
,
options
)
{
DAOFactory
.
prototype
.
build
=
function
(
values
,
options
)
{
var
start
=
tk
.
time
();
var
instance
=
new
DAO
(
values
,
Utils
.
_
.
extend
(
this
.
options
,
{
hasPrimaryKeys
:
this
.
hasPrimaryKeys
,
factory
:
this
}))
var
instance
=
new
DAO
(
values
,
Utils
.
_
.
extend
(
this
.
options
,
{
hasPrimaryKeys
:
this
.
hasPrimaryKeys
,
factory
:
this
}))
,
self
=
this
,
self
=
this
this
.
daoFactoryManager
.
sequelize
.
_metric
(
'DAOFactory.newDAO'
,
tk
.
time
()
-
start
);
options
=
options
||
{}
options
=
options
||
{}
instance
.
__factory
=
this
instance
.
__factory
=
this
...
@@ -228,7 +219,6 @@ module.exports = (function() {
...
@@ -228,7 +219,6 @@ module.exports = (function() {
instance
.
isNewRecord
=
options
.
hasOwnProperty
(
'isNewRecord'
)
?
options
.
isNewRecord
:
true
instance
.
isNewRecord
=
options
.
hasOwnProperty
(
'isNewRecord'
)
?
options
.
isNewRecord
:
true
instance
.
selectedValues
=
values
instance
.
selectedValues
=
values
this
.
daoFactoryManager
.
sequelize
.
_metric
(
'DAOFactory.build'
,
tk
.
time
()
-
start
);
return
instance
return
instance
}
}
...
...
lib/dao.js
View file @
7ce71c6
...
@@ -2,11 +2,8 @@ var Utils = require("./utils")
...
@@ -2,11 +2,8 @@ var Utils = require("./utils")
,
Mixin
=
require
(
"./associations/mixin"
)
,
Mixin
=
require
(
"./associations/mixin"
)
,
Validator
=
require
(
"validator"
)
,
Validator
=
require
(
"validator"
)
var
tk
=
require
(
'timekit'
);
module
.
exports
=
(
function
()
{
module
.
exports
=
(
function
()
{
var
DAO
=
function
(
values
,
options
)
{
var
DAO
=
function
(
values
,
options
)
{
var
start
=
tk
.
time
();
this
.
attributes
=
[]
this
.
attributes
=
[]
this
.
validators
=
{}
// holds validation settings for each attribute
this
.
validators
=
{}
// holds validation settings for each attribute
this
.
__factory
=
options
.
factory
||
null
// will be set by DAO.build if not present
this
.
__factory
=
options
.
factory
||
null
// will be set by DAO.build if not present
...
@@ -18,8 +15,6 @@ module.exports = (function() {
...
@@ -18,8 +15,6 @@ module.exports = (function() {
},
options
||
{})
},
options
||
{})
initAttributes
.
call
(
this
,
values
)
initAttributes
.
call
(
this
,
values
)
this
.
sequelize
.
_metric
(
'DAO.construct'
,
tk
.
time
()
-
start
);
}
}
Utils
.
_
.
extend
(
DAO
.
prototype
,
Mixin
.
prototype
)
Utils
.
_
.
extend
(
DAO
.
prototype
,
Mixin
.
prototype
)
...
...
lib/dialects/abstract/query.js
View file @
7ce71c6
...
@@ -71,7 +71,6 @@ module.exports = (function() {
...
@@ -71,7 +71,6 @@ module.exports = (function() {
result
=
data
result
=
data
}
}
this
.
sequelize
.
_metric
(
"AbstractQuery.formatResults"
,
tk
.
time
()
-
start
);
return
result
return
result
}
}
...
@@ -207,7 +206,6 @@ module.exports = (function() {
...
@@ -207,7 +206,6 @@ module.exports = (function() {
}
}
var
handleSelectQuery
=
function
(
results
)
{
var
handleSelectQuery
=
function
(
results
)
{
var
start
=
tk
.
time
();
var
result
=
null
,
self
=
this
;
var
result
=
null
,
self
=
this
;
if
(
this
.
options
.
raw
)
{
if
(
this
.
options
.
raw
)
{
...
@@ -238,7 +236,6 @@ module.exports = (function() {
...
@@ -238,7 +236,6 @@ module.exports = (function() {
result
=
(
result
.
length
===
0
)
?
null
:
result
[
0
]
result
=
(
result
.
length
===
0
)
?
null
:
result
[
0
]
}
}
this
.
sequelize
.
_metric
(
"handleSelectQuery"
,
tk
.
time
()
-
start
);
return
result
return
result
}
}
...
...
lib/dialects/mysql/query.js
View file @
7ce71c6
...
@@ -16,9 +16,7 @@ module.exports = (function() {
...
@@ -16,9 +16,7 @@ module.exports = (function() {
}
}
Utils
.
inherit
(
Query
,
AbstractQuery
)
Utils
.
inherit
(
Query
,
AbstractQuery
)
var
tk
=
require
(
'timekit'
);
Query
.
prototype
.
run
=
function
(
sql
)
{
Query
.
prototype
.
run
=
function
(
sql
)
{
var
start
=
tk
.
time
();
this
.
sql
=
sql
this
.
sql
=
sql
if
(
this
.
options
.
logging
!==
false
)
{
if
(
this
.
options
.
logging
!==
false
)
{
...
@@ -26,7 +24,6 @@ module.exports = (function() {
...
@@ -26,7 +24,6 @@ module.exports = (function() {
}
}
this
.
client
.
query
(
this
.
sql
,
function
(
err
,
results
,
fields
)
{
this
.
client
.
query
(
this
.
sql
,
function
(
err
,
results
,
fields
)
{
this
.
sequelize
.
_metric
(
'SQL'
,
tk
.
time
()
-
start
);
this
.
emit
(
'sql'
,
this
.
sql
)
this
.
emit
(
'sql'
,
this
.
sql
)
if
(
err
)
{
if
(
err
)
{
...
@@ -35,8 +32,6 @@ module.exports = (function() {
...
@@ -35,8 +32,6 @@ module.exports = (function() {
this
.
emit
(
'success'
,
this
.
formatResults
(
results
))
this
.
emit
(
'success'
,
this
.
formatResults
(
results
))
}
}
}.
bind
(
this
)).
setMaxListeners
(
100
)
}.
bind
(
this
)).
setMaxListeners
(
100
)
this
.
sequelize
.
_metric
(
'Query.run'
,
tk
.
time
()
-
start
);
return
this
return
this
}
}
...
...
lib/query-interface.js
View file @
7ce71c6
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
this
.
QueryGenerator
=
require
(
'./dialects/'
+
this
.
sequelize
.
options
.
dialect
+
'/query-generator'
)
this
.
QueryGenerator
=
require
(
'./dialects/'
+
this
.
sequelize
.
options
.
dialect
+
'/query-generator'
)
this
.
QueryGenerator
.
options
=
this
.
sequelize
.
options
;
this
.
QueryGenerator
.
options
=
this
.
sequelize
.
options
;
}
}
Utils
.
addEventEmitter
(
QueryInterface
)
Utils
.
addEventEmitter
(
QueryInterface
)
...
@@ -196,20 +194,17 @@ module.exports = (function() {
...
@@ -196,20 +194,17 @@ module.exports = (function() {
return
queryAndEmit
.
call
(
this
,
[
sql
,
dao
],
'delete'
)
return
queryAndEmit
.
call
(
this
,
[
sql
,
dao
],
'delete'
)
}
}
var
tk
=
require
(
'timekit'
);
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!
// 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
&&
!
Utils
.
_
.
isEmpty
(
options
)
&&
!
options
.
hasOwnProperty
(
'order'
)
&&
!
options
.
hasOwnProperty
(
'group'
)
&&
!
options
.
hasOwnProperty
(
'limit'
))
{
if
(
!
options
.
hasOwnProperty
(
'where'
))
{
if
(
!
options
.
hasOwnProperty
(
'where'
))
{
options
=
{
where
:
options
};
options
=
{
where
:
options
};
}
else
{
}
else
{
if
(
Utils
.
_
.
isEmpty
(
options
.
where
))
options
=
{};
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'
)
}
}
...
@@ -250,7 +245,6 @@ module.exports = (function() {
...
@@ -250,7 +245,6 @@ module.exports = (function() {
var
queryAndEmit
=
function
(
sqlOrQueryParams
,
methodName
,
options
)
{
var
queryAndEmit
=
function
(
sqlOrQueryParams
,
methodName
,
options
)
{
var
self
=
this
var
self
=
this
var
start
=
tk
.
time
();
options
=
Utils
.
_
.
extend
({
options
=
Utils
.
_
.
extend
({
success
:
function
(){},
success
:
function
(){},
...
...
lib/sequelize.js
View file @
7ce71c6
...
@@ -88,16 +88,6 @@ module.exports = (function() {
...
@@ -88,16 +88,6 @@ module.exports = (function() {
return
this
.
migrator
return
this
.
migrator
}
}
Sequelize
.
prototype
.
_metric
=
function
(
label
,
time
,
reset
)
{
if
(
reset
===
undefined
)
reset
=
false
;
if
(
!
this
.
_metrics
)
this
.
_metrics
=
{};
if
(
!
time
&&
this
.
_metrics
[
label
])
return
this
.
_metrics
[
label
];
if
(
!
time
&&
label
)
return
label
+
' wasn\'t logged'
;
if
(
!
time
&&
!
label
)
return
this
.
_metrics
;
if
(
!
this
.
_metrics
[
label
]
||
reset
)
this
.
_metrics
[
label
]
=
[];
this
.
_metrics
[
label
].
push
(
time
);
}
Sequelize
.
prototype
.
define
=
function
(
daoName
,
attributes
,
options
)
{
Sequelize
.
prototype
.
define
=
function
(
daoName
,
attributes
,
options
)
{
options
=
options
||
{}
options
=
options
||
{}
if
(
this
.
options
.
define
)
{
if
(
this
.
options
.
define
)
{
...
...
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