Commit a0d32c21 authored by Milan Wikarski's avatar Milan Wikarski

BEGIN and COMMIT changes

parent 0c69c357
......@@ -96,9 +96,7 @@ class Database {
throw new Error('A transaction is already active');
}
return this.query('BEGIN')
.execute()
.then(() => (this._transaction = true));
return this.query('BEGIN');
}
/**
......@@ -106,14 +104,12 @@ class Database {
*
* @returns {Promise.<Boolean>} success
*/
commit() {
async commit() {
if (!this._transaction) {
throw new Error('No transaction is active');
}
return this.query('COMMIT')
.execute()
.then(() => (this._transaction = false));
return this.query('COMMIT');
}
}
......
......@@ -46,7 +46,7 @@ const del = async () => {
};
const update = async () => {
await db.begin();
console.log(await db.begin());
console.log('UPDATE');
const update = db
......@@ -61,7 +61,7 @@ const update = async () => {
console.log(update.err);
}
await db.commit();
console.log(await db.commit());
};
(async () => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment