Skip to content

Commit

Permalink
Modernised Usage example in README
Browse files Browse the repository at this point in the history
  • Loading branch information
daniellockyer committed Apr 13, 2022
1 parent 9d05c55 commit 33d0656
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,21 +69,21 @@ See the [API documentation](https://github.com/TryGhost/node-sqlite3/wiki/API) i
**Note:** the module must be [installed](#installing) before use.

``` js
var sqlite3 = require('sqlite3').verbose();
var db = new sqlite3.Database(':memory:');
const sqlite3 = require('sqlite3').verbose();
const db = new sqlite3.Database(':memory:');

db.serialize(function() {
db.run("CREATE TABLE lorem (info TEXT)");
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();
const stmt = db.prepare("INSERT INTO lorem VALUES (?)");
for (let i = 0; i < 10; i++) {
stmt.run("Ipsum " + i);
}
stmt.finalize();

db.each("SELECT rowid AS id, info FROM lorem", function(err, row) {
console.log(row.id + ": " + row.info);
});
db.each("SELECT rowid AS id, info FROM lorem", (err, row) => {
console.log(row.id + ": " + row.info);
});
});

db.close();
Expand Down

0 comments on commit 33d0656

Please sign in to comment.