s3db.js 3.1.1 → 3.2.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.
- package/dist/s3db.cjs.js +15 -5
- package/dist/s3db.cjs.min.js +4 -4
- package/dist/s3db.es.js +15 -5
- package/dist/s3db.es.min.js +4 -4
- package/dist/s3db.iife.js +15 -5
- package/dist/s3db.iife.min.js +4 -4
- package/package.json +1 -1
package/dist/s3db.es.js
CHANGED
|
@@ -1334,9 +1334,9 @@ const SchemaActions = {
|
|
|
1334
1334
|
toString: (value) => String(value),
|
|
1335
1335
|
fromArray: (value, { separator }) => (value || []).join(separator),
|
|
1336
1336
|
toArray: (value, { separator }) => (value || "").split(separator),
|
|
1337
|
-
toNumber: (value) => isString$1(value) ? value.includes(".") ? parseFloat(value) : parseInt(value) : value,
|
|
1338
1337
|
toJSON: (value) => JSON.stringify(value),
|
|
1339
|
-
fromJSON: (value) => JSON.parse(value)
|
|
1338
|
+
fromJSON: (value) => JSON.parse(value),
|
|
1339
|
+
toNumber: (value) => isString$1(value) ? value.includes(".") ? parseFloat(value) : parseInt(value) : value
|
|
1340
1340
|
};
|
|
1341
1341
|
class Schema {
|
|
1342
1342
|
constructor(args) {
|
|
@@ -1363,7 +1363,7 @@ class Schema {
|
|
|
1363
1363
|
this.reversedMap = invert(map);
|
|
1364
1364
|
} else {
|
|
1365
1365
|
const flatAttrs = flatten(this.attributes, { safe: true });
|
|
1366
|
-
this.reversedMap = { ...Object.keys(flatAttrs).filter((k) => !k.
|
|
1366
|
+
this.reversedMap = { ...Object.keys(flatAttrs).filter((k) => !k.includes("$$")) };
|
|
1367
1367
|
this.map = invert(this.reversedMap);
|
|
1368
1368
|
}
|
|
1369
1369
|
}
|
|
@@ -1405,8 +1405,8 @@ class Schema {
|
|
|
1405
1405
|
this.addHook("afterUnmap", name, "toNumber");
|
|
1406
1406
|
}
|
|
1407
1407
|
if (definition.includes("boolean")) {
|
|
1408
|
-
this.addHook("beforeMap", name, "
|
|
1409
|
-
this.addHook("afterUnmap", name, "
|
|
1408
|
+
this.addHook("beforeMap", name, "toJSON");
|
|
1409
|
+
this.addHook("afterUnmap", name, "fromJSON");
|
|
1410
1410
|
}
|
|
1411
1411
|
}
|
|
1412
1412
|
}
|
|
@@ -1676,6 +1676,16 @@ class Resource extends EventEmitter {
|
|
|
1676
1676
|
this.emit("get", data);
|
|
1677
1677
|
return data;
|
|
1678
1678
|
}
|
|
1679
|
+
async exists(id) {
|
|
1680
|
+
try {
|
|
1681
|
+
await this.client.headObject(
|
|
1682
|
+
join(`resource=${this.name}`, `id=${id}`)
|
|
1683
|
+
);
|
|
1684
|
+
return true;
|
|
1685
|
+
} catch (error) {
|
|
1686
|
+
return false;
|
|
1687
|
+
}
|
|
1688
|
+
}
|
|
1679
1689
|
async update(id, attributes) {
|
|
1680
1690
|
const live = await this.get(id);
|
|
1681
1691
|
const attrs = merge(live, attributes);
|