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 4189f2b0
authored
Mar 29, 2011
by
Sascha Depold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
return the results when handling select queries
1 parent
5abd105c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
5 deletions
lib/sequelize/query.js
lib/sequelize/query.js
View file @
4189f2b
var
Utils
=
require
(
"./utils"
)
var
Utils
=
require
(
"./utils"
)
var
Query
=
module
.
exports
=
function
(
databaseConfig
,
callee
)
{
var
Query
=
module
.
exports
=
function
(
databaseConfig
,
callee
,
options
)
{
this
.
config
=
databaseConfig
this
.
config
=
databaseConfig
this
.
callee
=
callee
this
.
callee
=
callee
this
.
options
=
options
}
}
Utils
.
addEventEmitter
(
Query
)
Utils
.
addEventEmitter
(
Query
)
...
@@ -18,13 +19,20 @@ Query.prototype.run = function(query) {
...
@@ -18,13 +19,20 @@ Query.prototype.run = function(query) {
console
.
log
(
'Executing: '
+
query
)
console
.
log
(
'Executing: '
+
query
)
client
.
connect
()
client
.
connect
()
client
.
query
(
query
,
function
(
err
,
info
)
{
client
.
query
(
query
,
function
(
err
,
results
,
fields
)
{
if
(
err
)
{
if
(
err
)
{
self
.
emit
(
'failure'
,
err
,
self
.
callee
)
self
.
emit
(
'failure'
,
err
,
self
.
callee
)
}
else
{
}
else
{
if
(
self
.
callee
&&
(
query
.
indexOf
(
'INSERT INTO'
)
==
0
)
&&
(
info
.
hasOwnProperty
(
'insertId'
)))
var
result
=
self
.
callee
self
.
callee
.
id
=
info
.
insertId
self
.
emit
(
'success'
,
self
.
callee
)
if
(
self
.
callee
&&
(
query
.
indexOf
(
'INSERT INTO'
)
==
0
)
&&
(
results
.
hasOwnProperty
(
'insertId'
)))
self
.
callee
.
id
=
results
.
insertId
if
(
query
.
indexOf
(
'SELECT'
)
==
0
)
{
// will transform result into models
result
=
results
.
map
(
function
(
result
)
{
return
self
.
callee
.
build
(
result
)
})
}
self
.
emit
(
'success'
,
result
)
}
}
})
})
client
.
end
()
client
.
end
()
...
...
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