Commit a0d32c21 authored by Milan Wikarski's avatar Milan Wikarski

BEGIN and COMMIT changes

parent 0c69c357
...@@ -96,9 +96,7 @@ class Database { ...@@ -96,9 +96,7 @@ class Database {
throw new Error('A transaction is already active'); throw new Error('A transaction is already active');
} }
return this.query('BEGIN') return this.query('BEGIN');
.execute()
.then(() => (this._transaction = true));
} }
/** /**
...@@ -106,14 +104,12 @@ class Database { ...@@ -106,14 +104,12 @@ class Database {
* *
* @returns {Promise.<Boolean>} success * @returns {Promise.<Boolean>} success
*/ */
commit() { async commit() {
if (!this._transaction) { if (!this._transaction) {
throw new Error('No transaction is active'); throw new Error('No transaction is active');
} }
return this.query('COMMIT') return this.query('COMMIT');
.execute()
.then(() => (this._transaction = false));
} }
} }
......
...@@ -46,7 +46,7 @@ const del = async () => { ...@@ -46,7 +46,7 @@ const del = async () => {
}; };
const update = async () => { const update = async () => {
await db.begin(); console.log(await db.begin());
console.log('UPDATE'); console.log('UPDATE');
const update = db const update = db
...@@ -61,7 +61,7 @@ const update = async () => { ...@@ -61,7 +61,7 @@ const update = async () => {
console.log(update.err); console.log(update.err);
} }
await db.commit(); console.log(await db.commit());
}; };
(async () => { (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