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
ef859feb
Commit
ef859feb
authored
Mar 23, 2010
by
Orlando Vazquez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tentatively remove query queuing since it may not be exactly require
parent
30507228
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
33 deletions
+32
-33
sqlite.js
sqlite.js
+32
-33
No files found.
sqlite.js
View file @
ef859feb
...
@@ -20,39 +20,38 @@ var sqlite = require("./sqlite3_bindings");
...
@@ -20,39 +20,38 @@ var sqlite = require("./sqlite3_bindings");
var
Database
=
exports
.
Database
=
function
()
{
var
Database
=
exports
.
Database
=
function
()
{
var
self
=
this
;
var
self
=
this
;
this
.
queue
=
[];
this
.
driver
=
new
sqlite
.
Database
();
this
.
driver
.
addListener
(
"ready"
,
function
()
{
self
.
dispatch
();
});
};
Database
.
prototype
.
dispatch
=
function
()
{
var
db
=
new
sqlite
.
Database
();
if
(
!
this
.
queue
||
this
.
currentQuery
db
.
__proto__
=
Database
.
prototype
;
||
!
this
.
queue
.
length
)
{
return
;
}
this
.
currentQuery
=
this
.
queue
.
shift
();
this
.
executeQuery
.
apply
(
this
,
this
.
currentQuery
);
}
Database
.
prototype
.
open
=
function
()
{
// this.queue = [];
this
.
driver
.
open
.
apply
(
this
.
driver
,
arguments
);
//
}
// this.addListener("ready", function () {
// db.dispatch();
// });
Database
.
prototype
.
close
=
function
()
{
return
db
;
this
.
driver
.
close
.
apply
(
this
.
driver
,
arguments
);
};
}
Database
.
prototype
.
prepare
=
function
()
{
Database
.
prototype
=
{
this
.
driver
.
prepare
.
apply
(
this
.
driver
,
arguments
);
__proto__
:
sqlite
.
Database
.
prototype
,
}
constructor
:
Database
,
};
Database
.
prototype
.
query
=
function
(
sql
,
bindings
,
queryCallback
)
{
// Database.prototype.dispatch = function () {
this
.
queue
=
this
.
queue
||
[];
// if (!this.queue || this.currentQuery
this
.
queue
.
push
([
sql
,
bindings
,
queryCallback
]);
// || !this.queue.length) {
this
.
dispatch
();
// return;
}
// }
// this.currentQuery = this.queue.shift();
// this.executeQuery.apply(this, this.currentQuery);
// }
// Database.prototype.query = function (sql, bindings, queryCallback) {
// this.queue = this.queue || [];
// this.queue.push([sql, bindings, queryCallback]);
// this.dispatch();
// }
// Iterate over the list of bindings. Since we can't use something as
// 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
// simple as a for or while loop, we'll just chain them via the event loop
...
@@ -75,7 +74,7 @@ function _setBindingsByIndex(db,
...
@@ -75,7 +74,7 @@ function _setBindingsByIndex(db,
function
_queryDone
(
db
,
statement
)
{
function
_queryDone
(
db
,
statement
)
{
if
(
statement
.
tail
)
{
if
(
statement
.
tail
)
{
statement
.
finalize
(
function
()
{
statement
.
finalize
(
function
()
{
db
.
driver
.
prepare
(
statement
.
tail
,
onPrepare
);
db
.
prepare
(
statement
.
tail
,
onPrepare
);
});
});
return
;
return
;
}
}
...
@@ -83,7 +82,7 @@ function _queryDone(db, statement) {
...
@@ -83,7 +82,7 @@ function _queryDone(db, statement) {
statement
.
finalize
(
function
()
{
statement
.
finalize
(
function
()
{
db
.
currentQuery
=
undefined
;
db
.
currentQuery
=
undefined
;
// if there are any queries queued, let them know it's safe to go
// if there are any queries queued, let them know it's safe to go
db
.
driver
.
emit
(
"ready"
);
db
.
emit
(
"ready"
);
});
});
}
}
...
@@ -116,7 +115,7 @@ function _onPrepare(db, statement, bindings, rowCallback) {
...
@@ -116,7 +115,7 @@ function _onPrepare(db, statement, bindings, rowCallback) {
}
}
}
}
Database
.
prototype
.
executeQ
uery
=
function
(
sql
,
bindings
,
rowCallback
)
{
Database
.
prototype
.
q
uery
=
function
(
sql
,
bindings
,
rowCallback
)
{
var
self
=
this
;
var
self
=
this
;
if
(
typeof
(
bindings
)
==
"function"
)
{
if
(
typeof
(
bindings
)
==
"function"
)
{
...
@@ -124,7 +123,7 @@ Database.prototype.executeQuery = function(sql, bindings, rowCallback) {
...
@@ -124,7 +123,7 @@ Database.prototype.executeQuery = function(sql, bindings, rowCallback) {
bindings
=
[];
bindings
=
[];
}
}
this
.
driver
.
prepare
(
sql
,
function
(
error
,
statement
)
{
this
.
prepare
(
sql
,
function
(
error
,
statement
)
{
if
(
error
)
throw
error
;
if
(
error
)
throw
error
;
if
(
statement
)
{
if
(
statement
)
{
_onPrepare
(
self
,
statement
,
bindings
,
rowCallback
)
_onPrepare
(
self
,
statement
,
bindings
,
rowCallback
)
...
@@ -132,7 +131,7 @@ Database.prototype.executeQuery = function(sql, bindings, rowCallback) {
...
@@ -132,7 +131,7 @@ Database.prototype.executeQuery = function(sql, bindings, rowCallback) {
rowCallback
();
rowCallback
();
self
.
currentQuery
=
undefined
;
self
.
currentQuery
=
undefined
;
// if there are any queries queued, let them know it's safe to go
// if there are any queries queued, let them know it's safe to go
self
.
dispatch
();
//
self.dispatch();
}
}
});
});
}
}
...
...
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