有事务的Nodejsasynchronous模块

我想在我的nodejs项目中使用sqlite数据库。 我正在寻找一个模块为sqlite,这将是操作支持交易和asynchronous

另一个select是Knex 。 这是一个轻量级的查询生成器,它支持sqlite,mysql和postgres,有很好的文档,正在积极开发中。 Knex也支持承诺和callback,这是一个很好的接触。

通过简单的Transaction方法支持与Knex的交易。 这里是一个语法的例子:

http://knexjs.org/#Transaction

Knex.Transaction(function(t) { Knex('books') .transacting(t) .insert({name: 'Old Books'}) .then(function(row) { return When.all(_.map([ {title: 'Canterbury Tales'}, {title: 'Moby Dick'}, {title: 'Hamlet'} ], function(info) { info.row_id = row.id; // Some validation could take place here. return Knex('book').transacting(t).insert(info); })); }) .then(t.commit, t.rollback); }).then(function() { console.log('3 new books saved.'); }, function() { console.log('Error saving the books.'); }); 

这看起来像你最好的select: https : //github.com/developmentseed/node-sqlite3

请注意,我没有亲身经历。 但它是最stream行/活跃的,并支持事务( https://github.com/developmentseed/node-sqlite3/wiki/API#databaseexecsql-callback )。

find正确的node.js模块的一个好的起点: https : //nodejsmodules.org/tags/sqlite3