emilsoftware-utilities 1.2.7 → 1.2.9
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/.idea/inspectionProfiles/Project_Default.xml +9 -9
- package/orm.js +26 -9
- package/package.json +30 -30
- package/src/orm.ts +24 -9
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
<component name="InspectionProjectProfileManager">
|
|
2
|
-
<profile version="1.0">
|
|
3
|
-
<option name="myName" value="Project Default" />
|
|
4
|
-
<inspection_tool class="DuplicatedCode" enabled="true" level="WEAK WARNING" enabled_by_default="true">
|
|
5
|
-
<Languages>
|
|
6
|
-
<language minSize="63" name="TypeScript" />
|
|
7
|
-
</Languages>
|
|
8
|
-
</inspection_tool>
|
|
9
|
-
</profile>
|
|
1
|
+
<component name="InspectionProjectProfileManager">
|
|
2
|
+
<profile version="1.0">
|
|
3
|
+
<option name="myName" value="Project Default" />
|
|
4
|
+
<inspection_tool class="DuplicatedCode" enabled="true" level="WEAK WARNING" enabled_by_default="true">
|
|
5
|
+
<Languages>
|
|
6
|
+
<language minSize="63" name="TypeScript" />
|
|
7
|
+
</Languages>
|
|
8
|
+
</inspection_tool>
|
|
9
|
+
</profile>
|
|
10
10
|
</component>
|
package/orm.js
CHANGED
|
@@ -147,16 +147,33 @@ var rollbackTransaction = function (transaction) {
|
|
|
147
147
|
});
|
|
148
148
|
};
|
|
149
149
|
var executeQueries = function (transaction, queries, params) {
|
|
150
|
-
|
|
151
|
-
return
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
150
|
+
try {
|
|
151
|
+
return queries.reduce(function (promiseChain, currentQuery, index) {
|
|
152
|
+
return promiseChain.then(function () { return new Promise(function (resolve, reject) {
|
|
153
|
+
transaction.query(currentQuery, params[index], function (err, result) {
|
|
154
|
+
if (err)
|
|
155
|
+
return reject(err);
|
|
156
|
+
else
|
|
157
|
+
return resolve(result);
|
|
158
|
+
});
|
|
159
|
+
}); });
|
|
160
|
+
}, Promise.resolve())
|
|
161
|
+
.catch(function (error) {
|
|
162
|
+
return new Promise(function (resolve, reject) {
|
|
163
|
+
transaction.rollback(function (rollbackErr) {
|
|
164
|
+
if (rollbackErr) {
|
|
165
|
+
return reject(rollbackErr);
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
return reject(error);
|
|
169
|
+
}
|
|
170
|
+
});
|
|
157
171
|
});
|
|
158
|
-
});
|
|
159
|
-
}
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
catch (error) {
|
|
175
|
+
throw error;
|
|
176
|
+
}
|
|
160
177
|
};
|
|
161
178
|
exports.Orm = {
|
|
162
179
|
quote: quote,
|
package/package.json
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "emilsoftware-utilities",
|
|
3
|
-
"version": "1.2.
|
|
4
|
-
"description": "Utilities for EmilSoftware",
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"test": "echo \"Error: no test specified\" && exit 1",
|
|
8
|
-
"build": "tsc",
|
|
9
|
-
"prepublishOnly": "npm run build"
|
|
10
|
-
},
|
|
11
|
-
"repository": {
|
|
12
|
-
"type": "git",
|
|
13
|
-
"url": "git+https://github.com/mttdev382/emilsoftware-utilities.git"
|
|
14
|
-
},
|
|
15
|
-
"author": "",
|
|
16
|
-
"license": "ISC",
|
|
17
|
-
"bugs": {
|
|
18
|
-
"url": "https://github.com/mttdev382/emilsoftware-utilities/issues"
|
|
19
|
-
},
|
|
20
|
-
"homepage": "https://github.com/mttdev382/emilsoftware-utilities#readme",
|
|
21
|
-
"dependencies": {
|
|
22
|
-
"es-node-firebird": "^1.
|
|
23
|
-
"winston": "^3.11.0"
|
|
24
|
-
},
|
|
25
|
-
"devDependencies": {
|
|
26
|
-
"@types/express": "^4.17.21",
|
|
27
|
-
"@types/node": "^20.10.5",
|
|
28
|
-
"typescript": "^5.3.3"
|
|
29
|
-
}
|
|
30
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "emilsoftware-utilities",
|
|
3
|
+
"version": "1.2.9",
|
|
4
|
+
"description": "Utilities for EmilSoftware",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
8
|
+
"build": "tsc",
|
|
9
|
+
"prepublishOnly": "npm run build"
|
|
10
|
+
},
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/mttdev382/emilsoftware-utilities.git"
|
|
14
|
+
},
|
|
15
|
+
"author": "",
|
|
16
|
+
"license": "ISC",
|
|
17
|
+
"bugs": {
|
|
18
|
+
"url": "https://github.com/mttdev382/emilsoftware-utilities/issues"
|
|
19
|
+
},
|
|
20
|
+
"homepage": "https://github.com/mttdev382/emilsoftware-utilities#readme",
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"es-node-firebird": "^1.2.0",
|
|
23
|
+
"winston": "^3.11.0"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@types/express": "^4.17.21",
|
|
27
|
+
"@types/node": "^20.10.5",
|
|
28
|
+
"typescript": "^5.3.3"
|
|
29
|
+
}
|
|
30
|
+
}
|
package/src/orm.ts
CHANGED
|
@@ -116,16 +116,31 @@ const rollbackTransaction = (transaction: Transaction): Promise<any> => {
|
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
|
|
119
|
-
const executeQueries = (transaction: Transaction, queries: string[], params: any[]) => {
|
|
120
|
-
|
|
121
|
-
return
|
|
122
|
-
|
|
123
|
-
|
|
119
|
+
const executeQueries = (transaction: Transaction, queries: string[], params: any[]): Promise<any> => {
|
|
120
|
+
try {
|
|
121
|
+
return queries.reduce((promiseChain: Promise<any>, currentQuery: string, index: number) => {
|
|
122
|
+
return promiseChain.then(() => new Promise((resolve, reject) => {
|
|
123
|
+
transaction.query(currentQuery, params[index], (err: any, result: any): void => {
|
|
124
|
+
if (err) return reject(err);
|
|
125
|
+
else return resolve(result);
|
|
126
|
+
});
|
|
127
|
+
}));
|
|
128
|
+
}, Promise.resolve())
|
|
129
|
+
.catch(error => {
|
|
130
|
+
return new Promise((resolve, reject) => {
|
|
131
|
+
transaction.rollback((rollbackErr: any) => {
|
|
132
|
+
if (rollbackErr) {
|
|
133
|
+
return reject(rollbackErr);
|
|
134
|
+
} else {
|
|
135
|
+
return reject(error);
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
});
|
|
124
139
|
});
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
128
|
-
|
|
140
|
+
} catch (error) {
|
|
141
|
+
throw error;
|
|
142
|
+
}
|
|
143
|
+
};
|
|
129
144
|
|
|
130
145
|
interface Orm {
|
|
131
146
|
quote: (value: string) => string,
|