@superhero/db 0.5.2 → 1.0.0
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.
- package/adapter/mysql/index.js +5 -0
- package/adapter/mysql2/index.js +5 -0
- package/index.js +15 -4
- package/package.json +5 -2
package/adapter/mysql/index.js
CHANGED
package/adapter/mysql2/index.js
CHANGED
package/index.js
CHANGED
|
@@ -29,8 +29,19 @@ class Db
|
|
|
29
29
|
{
|
|
30
30
|
query = query.replace('?%s', ctx.shift())
|
|
31
31
|
}
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
|
|
33
|
+
try
|
|
34
|
+
{
|
|
35
|
+
return await this.adaptor.query(query, ...ctx)
|
|
36
|
+
}
|
|
37
|
+
catch(reason)
|
|
38
|
+
{
|
|
39
|
+
const error = new Error(`DB query '${file}' failed`)
|
|
40
|
+
error.code = 'DB_QUERY_ERROR'
|
|
41
|
+
error.query = this.adaptor.getFormattedQuery?.(query, ...ctx) ?? query
|
|
42
|
+
error.cause = reason
|
|
43
|
+
throw error
|
|
44
|
+
}
|
|
34
45
|
}
|
|
35
46
|
|
|
36
47
|
async formatQuery(file, formatCtx, sqlCtx)
|
|
@@ -56,8 +67,8 @@ class Db
|
|
|
56
67
|
: async (file, ...ctx) =>
|
|
57
68
|
{
|
|
58
69
|
const
|
|
59
|
-
|
|
60
|
-
|
|
70
|
+
query = await this.getQuery(file),
|
|
71
|
+
response = await transaction.query(query, ...ctx)
|
|
61
72
|
|
|
62
73
|
return response
|
|
63
74
|
}
|
package/package.json
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superhero/db",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Db interaction, designed to separate queries from the source code",
|
|
5
|
-
"repository":
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+ssh://git@github.com/superhero/js.db.git"
|
|
8
|
+
},
|
|
6
9
|
"main": "index.js",
|
|
7
10
|
"license": "MIT",
|
|
8
11
|
"author": {
|