Skip to content

Commit

Permalink
support for transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
Manuel Ortiz committed Aug 29, 2017
1 parent 78b8ffb commit 60f8447
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## Fork with transaction handling
Do not do anything extra, work out of the box


## loopback-connector-sqlite [![Build Status](https://travis-ci.org/Synerzip/loopback-connector-sqlite.svg)](https://travis-ci.org/Synerzip/loopback-connector-sqlite)
[**LoopBack**](http://loopback.io/) is a highly-extensible, open-source Node.js framework that enables you to create dynamic end-to-end REST APIs with little or no coding. It also enables you to access data from major relational databases, MongoDB, SOAP and REST APIs.

Expand Down
1 change: 1 addition & 0 deletions lib/sqlite3db.js
Original file line number Diff line number Diff line change
Expand Up @@ -999,3 +999,4 @@ if (!String.prototype.startsWith) {
}

require('./migration')(SQLiteDB);
require('./transactions')(SQLiteDB);
21 changes: 21 additions & 0 deletions lib/transactions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* Created by manuel.ortiz@fluxit.com.ar
*/

var async = require('async');
var sqlite3 = require("sqlite3");
var TransactionDatabase = require("sqlite3-transactions").TransactionDatabase;

module.exports = mixinTransactions;

function mixinTransactions(SQLiteDB) {

SQLiteDB.prototype.beginTransaction = (isolation, cb) => {
var db = new TransactionDatabase(new sqlite3.Database(":memory:", sqlite3.OPEN_READWRITE | sqlite3.OPEN_CREATE));
return db.beginTransaction(cb);
}

SQLiteDB.prototype.rollback = (tx, cb) => tx.rollback(cb);

SQLiteDB.prototype.commit = (tx, cb) => tx.commit(cb);
}
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "loopback-connector-sqlite",
"version": "1.4.5",
"version": "1.5.0",
"description": "LoopBack SQLite3 Database Connector. LoopBack is an API Mgmt/MBaas platform built on top of express by StrongLoop. It supports the notion of connectors to connect to databases, restful web services, soap web services etc.",
"main": "index.js",
"scripts": {
Expand All @@ -27,7 +27,8 @@
"async": "^0.9.0",
"debug": "^2.1.3",
"loopback-connector": "2.x",
"sqlite3": "^3.1.1"
"sqlite3": "^3.1.1",
"sqlite3-transactions": "^0.0.5"
},
"devDependencies": {
"chai": "^2.1.2",
Expand Down

0 comments on commit 60f8447

Please sign in to comment.