當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Database.each方法代碼示例

本文整理匯總了TypeScript中sqlite3.Database.each方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Database.each方法的具體用法?TypeScript Database.each怎麽用?TypeScript Database.each使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在sqlite3.Database的用法示例。


在下文中一共展示了Database.each方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: VALUES

  .then((data) => {
    console.log(data.cols);
    console.log(data.records);
    db.run("INSERT INTO memos VALUES('TEST', 5000)");

    db.each("SELECT * FROM memos", (err, row) => {
      console.log(row.text);
    });
  })
開發者ID:kimsk,項目名稱:try-typescript,代碼行數:9,代碼來源:parse-promise.ts

示例2: reject

 db.serialize(()=>{
     try{
         db.each(cmd, params, (err, data)=>{
             if(err){
                 reject(err);
                 return;
             }
             resolve(data);
         })
     }catch(e){
         reject(e);
     }
 });
開發者ID:D10221,項目名稱:xstore,代碼行數:13,代碼來源:sqliteAsync.ts

示例3: lorem

db.serialize(() => {
    db.run("CREATE TABLE lorem (info TEXT)");

    var stmt = db.prepare("INSERT INTO lorem VALUES (?)");
    for (var i = 0; i < 10; i++) {
        stmt.run("Ipsum " + i);
    }
    stmt.finalize();

    db.each("SELECT rowid AS id, info FROM lorem", (err, row) => {
        console.log(row.id + ": " + row.info);
    });
});
開發者ID:danelkhen,項目名稱:desktopbrowser,代碼行數:13,代碼來源:testsqlite.ts

示例4:

	db.serialize(() => {
		db.each(
			"SELECT channel_id, timestamp, type, nickname, user_id, message FROM chat WHERE channel_id=? AND timestamp>=? ORDER BY id",
			param.channelId,
			Date.now() - 1000 * 60 * 60 * 24 * 7,
			(err: Error, row: any) => {
				if (err === null) {
					let message: IMessage = {
						channelId: row.channel_id,
						timestamp: row.timestamp,
						type: row.type,
						message: row.message,
						nickname: row.nickname,
						userId: row.user_id,
					};
					event.sender.send("getChatLogs", JSON.stringify(message));
				} else {
					console.log(err);
				}
			}
			);
	});
開發者ID:data9824,項目名稱:SavannaTalk,代碼行數:22,代碼來源:main.ts

示例5: require

import * as _ from 'lodash';

import * as sqlite3 from 'sqlite3';

import * as fs from 'fs';
var parse = require('csv-parse');

var parser = parse({delimiter: ';'}, function(err, data){
  console.log(data);
});

fs.createReadStream(__dirname+'/../fs_read.csv').pipe(parser);

var db = new sqlite3.Database('test.db');

db.run("INSERT INTO memos VALUES('TEST', 5000)");

db.each("SELECT * FROM memos", (err, row) => {
  console.log(row.text);
});

db.close();

let arr: number[] = [1, 2, 3];

_.forEach(arr, (v) => console.log(v));

console.log('running...');
開發者ID:kimsk,項目名稱:try-typescript,代碼行數:28,代碼來源:app.ts

示例6: require

//
//					Feb/09/2016
//
// ------------------------------------------------------------
declare function require(x: string): any;
declare var process:any;
var sqlite3 = require("sqlite3");

// ------------------------------------------------------------
console.log ("*** 開始 ***");

var file_sqlite3: string = process.argv[2];

console.log (file_sqlite3);

var db = new sqlite3.Database (file_sqlite3);

var command: string = "select id,name,population,date_mod from cities";

db.each (command,function (err,row)
	{
	var str_out:string  = row.id + "\t" + row.name + "\t" + row.population;
	str_out += "\t" + row.date_mod;
	console.log (str_out);
	});

db.close ();

console.log ("*** 終了 ***");
// ------------------------------------------------------------
開發者ID:ekzemplaro,項目名稱:data_base_language,代碼行數:30,代碼來源:sqlite3_read.ts


注:本文中的sqlite3.Database.each方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。