Merge remote-tracking branch 'upstream/master' into merge_7_25

This commit is contained in:
Ryan Cavanaugh
2016-07-27 10:57:46 -07:00
312 changed files with 30687 additions and 5238 deletions
+9
View File
@@ -31,15 +31,19 @@ export declare class Statement {
public finalize(callback?: (err: Error) => void): Statement;
public run(callback?: (err: Error) => void): Statement;
public run(params: any, callback?: (err: Error) => void): Statement;
public run(...params: any[]): Statement;
public get(callback?: (err: Error, row: any) => void): Statement;
public get(params: any, callback?: (err: Error, row: any) => void): Statement;
public get(...params: any[]): Statement;
public all(callback?: (err: Error, rows: any[]) => void): Statement;
public all(params: any, callback?: (err: Error, rows: any[]) => void): Statement;
public all(...params: any[]): Statement;
public each(callback?: (err: Error, row: any) => void, complete?: (err: Error, count: number) => void): Statement;
public each(params: any, callback?: (err: Error, row: any) => void, complete?: (err: Error, count: number) => void): Statement;
public each(...params: any[]): Statement;
}
@@ -50,20 +54,25 @@ export declare class Database extends events.EventEmitter {
public close(callback?: (err: Error) => void): void;
public run(sql: string, callback?: (err: Error) => void): Database;
public run(sql: string, params: any, callback?: (err: Error) => void): Database;
public run(sql: string, ...params: any[]): Database;
public get(sql: string, callback?: (err: Error, row: any) => void): Database;
public get(sql: string, params: any, callback?: (err: Error, row: any) => void): Database;
public get(sql: string, ...params: any[]): Database;
public all(sql: string, callback?: (err: Error, rows: any[]) => void): Database;
public all(sql: string, params: any, callback?: (err: Error, rows: any[]) => void): Database;
public all(sql: string, ...params: any[]): Database;
public each(sql: string, callback?: (err: Error, row: any) => void, complete?: (err: Error, count: number) => void): Database;
public each(sql: string, params: any, callback?: (err: Error, row: any) => void, complete?: (err: Error, count: number) => void): Database;
public each(sql: string, ...params: any[]): Database;
public exec(sql: string, callback?: (err: Error) => void): Database;
public prepare(sql: string, callback?: (err: Error) => void): Statement;
public prepare(sql: string, params: any, callback?: (err: Error) => void): Statement;
public prepare(sql: string, ...params: any[]): Statement;
public serialize(callback?: () => void): void;
+12 -2
View File
@@ -31,10 +31,17 @@ function readAllRows() {
rows.forEach(function (row) {
console.log(row.id + ": " + row.info);
});
closeDb();
readSomeRows();
});
}
function readSomeRows() {
console.log("readAllRows lorem");
db.each("SELECT rowid AS id, info FROM lorem WHERE rowid < ? ", 5, function(err, row) {
console.log(row.id + ": " + row.info);
}, closeDb);
}
function closeDb() {
console.log("closeDb");
db.close();
@@ -63,7 +70,7 @@ db.serialize(function() {
db.serialize(function() {
// These two queries will run sequentially.
db.run("CREATE TABLE foo (num)");
db.run("INSERT INTO foo VALUES (?)", 1, function() {
db.run("INSERT INTO foo VALUES (?)", 1, function(err) {
// These queries will run in parallel and the second query will probably
// fail because the table might not exist yet.
db.run("CREATE TABLE bar (num)");
@@ -82,6 +89,9 @@ db.run("UPDATE tbl SET name = $name WHERE id = $id", {
$id: 2,
$name: "bar"
});
db.run("UPDATE tbl SET name = $name WHERE id = $id", { $id: 2, $name: "bar" },
function(err) { }
);
db.run("UPDATE tbl SET name = ?5 WHERE id = ?", {
1: 2,