...
 
Commits (2)
{
"name": "@creanet/js-db",
"version": "2.4.1",
"version": "2.5.0",
"description": "Used for communication between NodeJS and PostgreSQL",
"main": "index.js",
"scripts": {
......
......@@ -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 () => {
......