当前位置: 首页>>代码示例>>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;未经允许,请勿转载。