Promises has tons of advantages than callback. Do you guys think it's worth to put this on the road map?
Bluebird is really power promise library, in case you guys decide to support Promises
https://github.com/petkaantonov/bluebird
promises are not on the roadmap. node-sqlite is mostly in maintenance mode.
:+1: for promises
Here is a Promise-based wrapper for node-sqlite3: https://github.com/kriasoft/node-sqlite
import db from 'sqlite'; // For old versions of Node.js use: var db = require('sqlite/legacy');
import Promise from 'bluebird';
(async () => {
await db.open('./db.sqlite', { Promise });
await db.migrate(); // Migrate db schema to the latest version
const row = await db.get('SELECT * FROM TableName WHERE id = ?', 123);
const rows = await db.all('SELECT * FROM TableName');
// etc.
})();
UPDATE: Adding SQL-based migrations API to this library...
@koistya Nice ! Thanks.
Is there any API difference between node-sqlite and node-sqlite3?
Is it safe to migrate?? If so, that would be great.
@fritx sqlite npm module (node-sqlite) is just a tiny wrapper (see the source code) over the sqlite3 (node-sqlite3) library. It's intended to make it easier to write async code in a modern ES2015+ style.
@koistya awesome. But seems there is no API like new Database()?
Do I have to replace all of them with db.open()? Any more similar API?
Yep, instead of new Database(), you would just do db.open(..), the rest of the API is very similar to node-sqlite3.
Most helpful comment
Here is a Promise-based wrapper for
node-sqlite3: https://github.com/kriasoft/node-sqliteUPDATE: Adding SQL-based migrations API to this library...