Skip to content

Commit

Permalink
added support for transactions, for faster mass inserts
Browse files Browse the repository at this point in the history
  • Loading branch information
xavierlacot committed Mar 15, 2012
1 parent 8d9958f commit 82a44df
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions joli.js
Expand Up @@ -802,6 +802,27 @@ joli.record.prototype = {
}
};

joli.transaction = function(name) {
this.data = {
commited: false
};
};

joli.transaction.prototype = {
begin: function() {
joli.connection.execute('BEGIN;');
},

commit: function() {
if (this.data.commited) {
throw new Error('The transaction was already commited!');
}

joli.connection.execute('COMMIT;');
this.data.commited = true;
},
};

/**
* In case joli.js is loaded as a CommonJS module
*/
Expand Down

0 comments on commit 82a44df

Please sign in to comment.