utilitas 2001.1.105 → 2001.1.106

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/lib/dbio.mjs CHANGED
@@ -15,7 +15,7 @@ const RETURNING_ALL = ` RETURNING *`;
15
15
  const [fieldId, fieldAny] = ['id', '*'];
16
16
  const fieldCount = `COUNT(${fieldAny})`;
17
17
  const direct = { direct: true };
18
- const comparison = ['=', '>', '<', '<>', '!='];
18
+ const comparison = ['=', '>', '<', '<>', '!=', 'LIKE', 'NOT LIKE'];
19
19
  const fieldNoQuote = [fieldAny, fieldCount];
20
20
  const log = content => _log(content, import.meta.url);
21
21
  const defaultKey = options => options && options.key ? options.key : fieldId;
@@ -356,7 +356,7 @@ const queryByKeyValue = async (table, key, value, options) => {
356
356
 
357
357
  const queryById = async (table, id, options) => await queryByKeyValue(
358
358
  table, defaultKey(options), id,
359
- { ...options || {}, unique: !Array.isArray(id) }
359
+ { ...options || {}, unique: !Array.isArray(id) && !Object.isObject(id) }
360
360
  );
361
361
 
362
362
  const insert = async (table, fields, options) => {
package/lib/manifest.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  const manifest = {
2
2
  "name": "utilitas",
3
3
  "description": "Just another common utility for JavaScript.",
4
- "version": "2001.1.105",
4
+ "version": "2001.1.106",
5
5
  "private": false,
6
6
  "homepage": "https://github.com/Leask/utilitas",
7
7
  "main": "index.mjs",
package/lib/memory.mjs CHANGED
@@ -56,7 +56,9 @@ const handleResult = (resp, options) => {
56
56
  ensureArray(resp).map(x => { x.value = unpack(x.value); });
57
57
  let result = {};
58
58
  if (Array.isArray(resp)) {
59
- for (let i in resp) { result[resp[i].key] = resp[i].value; }
59
+ for (let i in resp) {
60
+ result[resp[i].key.split('/').pop()] = resp[i].value;
61
+ }
60
62
  } else { result = resp?.value; }
61
63
  resp = result;
62
64
  }
@@ -72,8 +74,15 @@ const set = async (key, value, options) => {
72
74
 
73
75
  const get = async (key, options) => {
74
76
  options = { ...options || {}, ...defaultKey };
75
- return handleResult(await ((key = assertKey(key, { ignoreError: true }))
76
- ? queryById(table, key, options) : queryAll(table, options)), options);
77
+ let result;
78
+ if ((key = assertKey(key, { ignoreError: true })) && !options?.asPrefix) {
79
+ result = queryById(table, key, options);
80
+ } else if (key && options?.asPrefix) {
81
+ result = queryById(table, { 'LIKE': `${key}/%` }, options);
82
+ } else {
83
+ result = queryAll(table, options);
84
+ }
85
+ return handleResult(await result, options);
77
86
  };
78
87
 
79
88
  const del = async (key, options) => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "utilitas",
3
3
  "description": "Just another common utility for JavaScript.",
4
- "version": "2001.1.105",
4
+ "version": "2001.1.106",
5
5
  "private": false,
6
6
  "homepage": "https://github.com/Leask/utilitas",
7
7
  "main": "index.mjs",