inibase 1.0.0-rc.87 → 1.0.0-rc.89

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.
Files changed (2) hide show
  1. package/dist/index.js +10 -7
  2. 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), schema = (await this.throwErrorIfTableEmpty(tableName)).schema;
1127
- this.validateData(data, schema, true);
1128
- await this.checkUnique(tableName, schema);
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(),
@@ -1180,6 +1180,9 @@ export default class Inibase {
1180
1180
  else if ((Array.isArray(where) && where.every(Utils.isNumber)) ||
1181
1181
  Utils.isNumber(where)) {
1182
1182
  // "where" in this case, is the line(s) number(s) and not id(s)
1183
+ this.validateData(data, schema, true);
1184
+ await this.checkUnique(tableName, schema);
1185
+ data = this.formatData(data, schema, true);
1183
1186
  const pathesContents = Object.fromEntries(Object.entries(this.joinPathesContents(tableName, Utils.isArrayOfObjects(data)
1184
1187
  ? data.map((item) => ({
1185
1188
  ...item,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "inibase",
3
- "version": "1.0.0-rc.87",
3
+ "version": "1.0.0-rc.89",
4
4
  "type": "module",
5
5
  "author": {
6
6
  "name": "Karim Amahtil",