Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
node-sqlite3
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
俞永鹏
node-sqlite3
Commits
e79ff0c4
Commit
e79ff0c4
authored
Mar 16, 2010
by
Orlando Vazquez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wip
parent
7fbb4ee5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
23 deletions
+24
-23
sqlite.js
sqlite.js
+18
-23
sqlite3_bindings.cc
sqlite3_bindings.cc
+6
-0
No files found.
sqlite.js
View file @
e79ff0c4
...
...
@@ -22,6 +22,9 @@ var Database = exports.Database = function () {
var
self
=
this
;
this
.
queue
=
[];
this
.
db
=
new
sqlite
.
Database
();
this
.
db
.
addListener
(
"ready"
,
function
()
{
self
.
dispatch
();
});
};
Database
.
prototype
.
dispatch
=
function
()
{
...
...
@@ -62,28 +65,24 @@ Database.prototype.executeQuery = function(sql, bindings, queryCallback) {
// Iterate over the list of bindings. Since we can't use something as
// simple as a for or while loop, we'll just chain them via the event loop
function
doBindingsByIndex
(
statement
,
bindings
,
queryCallback
)
{
(
function
(
statement
,
bindings
,
bindIndex
)
{
var
innerFunction
=
arguments
.
callee
;
function
doBindingsByIndex
(
statement
,
bindings
,
callback
)
{
var
innerFunction
=
function
(
statement
,
bindings
,
bindIndex
)
{
if
(
!
bindings
.
length
)
{
process
.
nextTick
(
function
()
{
queryCallback
(
statement
);
});
callback
(
statement
);
return
;
}
bindIndex
=
bindIndex
||
1
;
var
value
=
bindings
.
shift
();
process
.
nextTick
(
function
()
{
statement
.
bind
(
bindIndex
,
value
,
function
()
{
innerFunction
(
statement
,
bindings
,
bindIndex
+
1
);
});
statement
.
bind
(
bindIndex
,
value
,
function
()
{
innerFunction
(
statement
,
bindings
,
bindIndex
+
1
);
});
})(
statement
,
bindings
,
1
);
};
innerFunction
(
statement
,
bindings
,
1
);
}
function
queryDone
(
statement
,
rows
)
{
function
queryDone
(
statement
)
{
if
(
statement
.
tail
)
{
statement
.
finalize
(
function
()
{
self
.
db
.
prepare
(
statement
.
tail
,
onPrepare
);
...
...
@@ -93,30 +92,26 @@ Database.prototype.executeQuery = function(sql, bindings, queryCallback) {
statement
.
finalize
(
function
()
{
self
.
currentQuery
=
undefined
;
queryCallback
(
undefined
,
rows
);
// if there are any queries queued, let them know it's safe to go
self
.
db
.
emit
(
"ready"
);
});
}
function
doStep
(
statement
)
{
var
rows
=
[];
(
function
()
{
var
innerFunction
=
arguments
.
callee
;
var
innerFunction
=
function
()
{
statement
.
step
(
function
(
error
,
row
)
{
if
(
error
)
throw
error
;
if
(
error
)
throw
error
;
if
(
!
row
)
{
// rows.rowsAffected = this.changes();
// rows.insertId = this.lastInsertRowid();
process
.
nextTick
(
function
()
{
queryDone
(
statement
,
rows
);
});
queryDone
(
statement
);
return
;
}
rows
.
push
(
row
);
process
.
nextTick
(
innerFunction
);
queryCallback
(
row
);
innerFunction
(
);
});
})();
};
innerFunction
();
}
function
onPrepare
(
error
,
statement
)
{
...
...
sqlite3_bindings.cc
View file @
e79ff0c4
...
...
@@ -775,6 +775,12 @@ protected:
free
((
int
*
)(
step_req
->
column_data
[
i
]));
break
;
case
SQLITE_FLOAT
:
row
->
Set
(
String
::
New
(
step_req
->
column_names
[
i
]),
Number
::
New
(
*
(
double
*
)
(
step_req
->
column_data
[
i
])));
free
((
double
*
)(
step_req
->
column_data
[
i
]));
break
;
case
SQLITE_TEXT
:
row
->
Set
(
String
::
New
(
step_req
->
column_names
[
i
]),
String
::
New
((
char
*
)
(
step_req
->
column_data
[
i
])));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment