inibase 1.0.0-rc.87 → 1.0.0-rc.88
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/index.js +7 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1123,18 +1123,15 @@ export default class Inibase {
|
|
|
1123
1123
|
perPage: 15,
|
|
1124
1124
|
}, returnUpdatedData) {
|
|
1125
1125
|
let renameList = [];
|
|
1126
|
-
const tablePath = join(this.databasePath, tableName)
|
|
1127
|
-
this.
|
|
1128
|
-
|
|
1129
|
-
data = this.formatData(data, schema, true);
|
|
1126
|
+
const tablePath = join(this.databasePath, tableName);
|
|
1127
|
+
const schema = (await this.throwErrorIfTableEmpty(tableName))
|
|
1128
|
+
.schema;
|
|
1130
1129
|
if (!where) {
|
|
1131
1130
|
if (Utils.isArrayOfObjects(data)) {
|
|
1132
1131
|
if (!data.every((item) => Object.hasOwn(item, "id") && Utils.isValidID(item.id)))
|
|
1133
1132
|
throw this.throwError("INVALID_ID");
|
|
1134
1133
|
// TODO: Reduce I/O
|
|
1135
|
-
return this.put(tableName, data, data
|
|
1136
|
-
.filter(({ id }) => id !== undefined)
|
|
1137
|
-
.map(({ id }) => id));
|
|
1134
|
+
return this.put(tableName, data, data.map(({ id }) => id));
|
|
1138
1135
|
}
|
|
1139
1136
|
if (Object.hasOwn(data, "id")) {
|
|
1140
1137
|
if (!Utils.isValidID(data.id))
|
|
@@ -1148,6 +1145,9 @@ export default class Inibase {
|
|
|
1148
1145
|
.map(Number)[1];
|
|
1149
1146
|
else
|
|
1150
1147
|
totalItems = await File.count(join(tablePath, `id${this.getFileExtension(tableName)}`));
|
|
1148
|
+
this.validateData(data, schema, true);
|
|
1149
|
+
await this.checkUnique(tableName, schema);
|
|
1150
|
+
data = this.formatData(data, schema, true);
|
|
1151
1151
|
const pathesContents = this.joinPathesContents(tableName, {
|
|
1152
1152
|
...(({ id, ...restOfData }) => restOfData)(data),
|
|
1153
1153
|
updatedAt: Date.now(),
|