Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

match code formatting

  • Loading branch information...
commit 09b55954b26ce183443e1080477d5678e36c12bb 1 parent 6a666dd
Konstantin Käfer authored
Showing with 26 additions and 31 deletions.
  1. +26 −31 examples/simple-chaining.js
View
57 examples/simple-chaining.js
@@ -1,55 +1,50 @@
-/*
- Shows how to use chaining rather than the `serialize` method
-*/
-(function () {
- "use strict";
+/**
+ * Shows how to use chaining rather than the `serialize` method.
+ */
+"use strict";
- require('long-stack-traces');
+var sqlite3 = require('sqlite3').verbose();
+var db;
- var sqlite3 = require('sqlite3').verbose(),
- db;
-
- function createDb() {
+function createDb() {
console.log("createDb chain");
db = new sqlite3.Database('chain.sqlite3', createTable);
- }
+}
- function createTable() {
+function createTable() {
console.log("createTable lorem");
db.run("CREATE TABLE IF NOT EXISTS lorem (info TEXT)", insertRows);
- }
+}
- function insertRows() {
+function insertRows() {
console.log("insertRows Ipsum i");
- var stmt = db.prepare("INSERT INTO lorem VALUES (?)"),
- i;
+ var stmt = db.prepare("INSERT INTO lorem VALUES (?)");
- for (i = 0; i < 10; i++) {
- stmt.run("Ipsum " + i);
+ for (var i = 0; i < 10; i++) {
+ stmt.run("Ipsum " + i);
}
stmt.finalize(readAllRows);
- }
+}
- function readAllRows() {
+function readAllRows() {
console.log("readAllRows lorem");
db.all("SELECT rowid AS id, info FROM lorem", function(err, rows) {
- rows.forEach(function (row) {
- console.log(row.id + ": " + row.info);
- });
- closeDb();
+ rows.forEach(function (row) {
+ console.log(row.id + ": " + row.info);
+ });
+ closeDb();
});
- }
+}
- function closeDb() {
+function closeDb() {
console.log("closeDb");
db.close();
- }
+}
- function runChainExample() {
+function runChainExample() {
createDb();
- }
+}
- runChainExample();
-}());
+runChainExample();
Please sign in to comment.
Something went wrong with that request. Please try again.