Permalink
Browse files

match code formatting

  • Loading branch information...
1 parent 6a666dd commit 09b55954b26ce183443e1080477d5678e36c12bb @kkaefer kkaefer committed Feb 28, 2011
Showing with 26 additions and 31 deletions.
  1. +26 −31 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();

0 comments on commit 09b5595

Please sign in to comment.