本文整理匯總了TypeScript中sqlite3.Database.close方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Database.close方法的具體用法?TypeScript Database.close怎麽用?TypeScript Database.close使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類sqlite3.Database
的用法示例。
在下文中一共展示了Database.close方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: users
.then(data => {
db.run(
"insert into users (username, salt, hashedpwd) values (?, ?, ?)",
[data.username, data.salt, data.hash], cb // Null on success, single error parameter on success
);
db.close();
});
示例2: reject
(err) => {
db.close();
if (err) {
reject(err);
} else {
resolve();
}
});
示例3: setupDatabase
/**
* Caution: resets database.
*/
static setupDatabase() {
try {
fs.unlinkSync(DB_PATH);
} catch (err) { }
let db = new Database(DB_PATH);
try {
db.serialize(() => {
db.run(`
CREATE TABLE users (
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE,
username TEXT NOT NULL UNIQUE,
salt TEXT NOT NULL,
hashedpwd TEXT NOT NULL,
admin INTEGER NOT NULL DEFAULT 0
);
`);
db.run(`
CREATE TABLE entries (
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE,
date TEXT NOT NULL,
hungerscore INTEGER NOT NULL,
hungertext TEXT,
cravingscore INTEGER NOT NULL,
cravingtext TEXT,
satietyscore INTEGER NOT NULL,
satietytext TEXT,
energyscore INTEGER NOT NULL,
energytext TEXT,
wellbeingscore INTEGER NOT NULL,
wellbeingtext TEXT,
carbsscore INTEGER NOT NULL,
carbstext TEXT,
stressambool INTEGER NOT NULL,
stresspmbool INTEGER NOT NULL,
walksbool INTEGER NOT NULL,
movementbool INTEGER NOT NULL,
movementtext TEXT,
bedtimebool INTEGER NOT NULL,
bedtimetext TEXT,
userid INTEGER NOT NULL,
FOREIGN KEY(userid) REFERENCES user(id)
);
`);
});
}
catch (err) { console.error(err); }
finally {
db.close();
}
}
示例4: resolve
return new Promise<any>((resolve, reject) => {
if (!this._db) {
resolve();
} else {
this._db.close(err => {
if (err) {
reject(err);
} else {
this._db = undefined;
resolve();
}
});
}
});
示例5: cities
for (var key in dict_aa)
{
var sql_str:string = "insert into cities (id,name,population,date_mod) values (";
var str_data: string = "'" + key + "','" + dict_aa[key].name + "',"
+ dict_aa[key].population + ",'" + dict_aa[key].date_mod + "')";
sql_str += str_data;
db.run (sql_str);
}
});
}
// ------------------------------------------------------------
console.log ("*** 開始 ***");
var file_sqlite3: string = process.argv[2];
console.log (file_sqlite3);
var dict_aa = data_prepare_proc ();
var db = new sqlite3.Database (file_sqlite3);
table_create_insert_proc (db,dict_aa);
db.close ();
console.log ("*** 終了 ***");
// ------------------------------------------------------------
示例6:
.then(() => {
console.log('close db..')
db.close();
});