utilitas 1995.2.67 → 1995.2.69
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/dist/utilitas.lite.mjs +1 -1
- package/dist/utilitas.lite.mjs.map +1 -1
- package/lib/dbio.mjs +6 -2
- package/lib/manifest.mjs +1 -1
- package/package.json +1 -1
package/lib/dbio.mjs
CHANGED
|
@@ -8,7 +8,7 @@ const _NEED = ['mysql2', 'pg'];
|
|
|
8
8
|
const [mysqlDefaultPort, postgresqlDefaultPort] = [3306, 5432];
|
|
9
9
|
const [mysqlQuote, postgresqlQuote] = ['`', ''];
|
|
10
10
|
const IFSC = 'information_schema';
|
|
11
|
-
const orders = { '+': 'ASC', '-': 'DESC' };
|
|
11
|
+
const orders = { '+': 'ASC', ASC: 'ASC', '-': 'DESC', DESC: 'DESC' };
|
|
12
12
|
const [INSERT, UPDATE, RETURNING] = ['INSERT', 'UPDATE', 'RETURNING'];
|
|
13
13
|
const RETURNING_ALL = ` RETURNING *`;
|
|
14
14
|
const [fieldId, fieldAny] = ['id', '*'];
|
|
@@ -189,6 +189,8 @@ const assembleQuery = (table, options) => {
|
|
|
189
189
|
};
|
|
190
190
|
|
|
191
191
|
const rawAssembleKeyValue = (key, value, options) => {
|
|
192
|
+
// TODO: handle JSONB for PostgreSQL only
|
|
193
|
+
// for MySQL, JSON should be stringified before assembling
|
|
192
194
|
assertKeyValue(key, value);
|
|
193
195
|
let _placeholder;
|
|
194
196
|
switch (provider) {
|
|
@@ -216,6 +218,7 @@ const pushValue = (values, item) => values.push(
|
|
|
216
218
|
);
|
|
217
219
|
|
|
218
220
|
const assembleSet = (data, options) => {
|
|
221
|
+
assertSet(data, 'Data is required.');
|
|
219
222
|
const [isArray, result] = [options?.asArray || Array.isArray(data), []];
|
|
220
223
|
ensureArray(data).map((item) => {
|
|
221
224
|
assert(Object.keys(item).length, 'Fields are required.', 500);
|
|
@@ -285,7 +288,8 @@ const assembleTail = (options) => {
|
|
|
285
288
|
sort.push(`${quote(key)} ${getOrder(ord[key])}`);
|
|
286
289
|
});
|
|
287
290
|
return (sort.length ? ` ORDER BY ${join(sort)}` : '')
|
|
288
|
-
+ (~~options?.limit ? ` LIMIT ${~~options.limit}` : '')
|
|
291
|
+
+ (~~options?.limit ? ` LIMIT ${~~options.limit}` : '')
|
|
292
|
+
+ (~~options?.offset ? ` OFFSET ${~~options.offset}` : '');
|
|
289
293
|
};
|
|
290
294
|
|
|
291
295
|
const tables = async (options) => {
|
package/lib/manifest.mjs
CHANGED