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


TypeScript Database.run方法代碼示例

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


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

示例1: users

 database.all("SELECT * FROM users WHERE user_id=$userid", { $userid: userid }, (err, rows) => {
    if (rows.length < 1) {
       database.run("INSERT INTO users(user_id, lastfm_name) VALUES ($userid, $lastfm)", { $userid: userid, $lastfm: lastfmName }, (err) => {
          if (err) reject(Util.errorMsg(err));
          resolve(rows);
       });
    } else {
       database.run("UPDATE users SET lastfm_name=$lastfm WHERE user_id=$userid", { $lastfm: lastfmName, $userid: userid }, (err) => {
          if (err) reject(Util.errorMsg(err));
          resolve(rows);
       });
    }
 });
開發者ID:Itachi2000,項目名稱:PS-Bot,代碼行數:13,代碼來源:userdao.ts

示例2: rooms

 database.all("SELECT * FROM rooms WHERE room_id=$roomid", { $roomid: roomid }, (err, rows) => {
   if (rows.length < 1) {
     database.run("INSERT INTO rooms(room_id, auto_join) VALUES ($roomid, $status)", { $roomid: roomid, $status: status }, (err) => {
       if (err) reject(Util.errorMsg(err));
       resolve(rows);
     });
   } else {
     database.run("UPDATE rooms SET auto_join=$status WHERE room_id=$roomid", { $status: status, $roomid: roomid }, (err) => {
       if (err) reject(Util.errorMsg(err));
       resolve(rows);
     });
   }
 });
開發者ID:Itachi2000,項目名稱:PS-Bot,代碼行數:13,代碼來源:roomdao.ts

示例3: 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();
 });
開發者ID:Ethan826,項目名稱:diet-tracker,代碼行數:7,代碼來源:db.ts

示例4: _rollbackTransaction

 private _rollbackTransaction(
     db: Database,
     error: Error,
     errorAction: (error: Error) => void) {
     db.run("ROLLBACK", err => {
         errorAction(error);
     });
 }
開發者ID:coatyio,項目名稱:coaty-js,代碼行數:8,代碼來源:sqlite-node-adapter.ts

示例5: reject

 db.serialize(()=>{
     db.run(sql, e=> {
         if (_.isError(e)) {
             reject(e);
             return;
         }
         resolve(true)
     })
 })
開發者ID:D10221,項目名稱:xstore,代碼行數:9,代碼來源:sqliteAsync.ts

示例6: 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

示例7: chat

			db.serialize(() => {
				db.run(
					"INSERT INTO chat (channel_id, timestamp, type, nickname, user_id, message) VALUES(?, ?, ?, ?, ?, ?)",
					message.channelId, message.timestamp, message.type, message.nickname, message.userId, message.message,
					(err: Error) => {
						if (err !== null) {
							mainWindow.webContents.send("error", "チャットを記録できません。:" + err.name + " " + err.message);
						}
					}
				);
			});
開發者ID:data9824,項目名稱:SavannaTalk,代碼行數:11,代碼來源:main.ts

示例8: _commitTransaction

 private _commitTransaction(
     db: Database,
     action: () => void,
     errorAction: (error: Error) => void) {
     db.run("COMMIT", err => {
         if (err) {
             errorAction(err);
         } else {
             action();
         }
     });
 }
開發者ID:coatyio,項目名稱:coaty-js,代碼行數:12,代碼來源:sqlite-node-adapter.ts

示例9: 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

示例10: Promise

    return new Promise((resolve, reject) => {

      switch (queryType) {
        case QueryType.SELECT:
          this.db.all(query, params, (err, rows) => {
            if (err) {
              reject(err);
            } else {
              resolve(rows);
            }
          });
          break;
        case QueryType.INSERT:
          this.db.run(query, params, function (err) {
            // Do not use arrow function so we can access 'this'
            // See https://github.com/mapbox/node-sqlite3/wiki/API#databaserunsql-param--callback
            if (err) {
              reject(err);
            } else {
              resolve(this.lastID);
            }
          });
          break;
        case QueryType.UPDATE:
        case QueryType.DELETE:
          this.db.run(query, params, function (err) {
            // Do not use arrow function so we can access 'this'
            // See https://github.com/mapbox/node-sqlite3/wiki/API#databaserunsql-param--callback
            if (err) {
              reject(err);
            } else {
              resolve(this.changes);
            }
          });
          break;

      }
    });
開發者ID:DavidLevayer,項目名稱:countable,代碼行數:38,代碼來源:sqlite.connector.ts


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