@superhero/db 1.0.1-rc.3.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -49,7 +49,9 @@ class AdapterMySql2
49
49
  try
50
50
  {
51
51
  const
52
- result = await connection.query('SELECT GET_LOCK(?, ?) as status', [reference, timeout]),
52
+ result = await new Promise((resolve, reject) =>
53
+ connection.query('SELECT GET_LOCK(?, ?) as status', [reference, timeout], (error, result) =>
54
+ error ? reject(error) : resolve(result))),
53
55
  status = result[0].status
54
56
 
55
57
  if(1 === status)
@@ -75,7 +77,9 @@ class AdapterMySql2
75
77
  }
76
78
  finally
77
79
  {
78
- await connection.query('DO RELEASE_LOCK(?)', [reference])
80
+ await new Promise((resolve, reject) =>
81
+ connection.query('DO RELEASE_LOCK(?)', [reference], (error) =>
82
+ error ? reject(error) : resolve()))
79
83
  .then(() => connection.release())
80
84
  .catch(() => connection.end())
81
85
  }
@@ -84,7 +88,9 @@ class AdapterMySql2
84
88
  async createTransaction(connection = null)
85
89
  {
86
90
  connection = connection ?? await this.getConnection()
87
- await connection.query('START TRANSACTION')
91
+ await new Promise((resolve, reject) =>
92
+ connection.query('START TRANSACTION', (error) =>
93
+ error ? reject(error) : resolve()))
88
94
  return new AdapterMySql2Transaction(connection)
89
95
  }
90
96
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superhero/db",
3
- "version": "1.0.1-rc.3.0",
3
+ "version": "1.0.1",
4
4
  "description": "Db interaction, designed to separate queries from the source code",
5
5
  "repository": {
6
6
  "type": "git",