@dnax/core 0.8.10 → 0.8.11

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.
@@ -108,6 +108,7 @@ class useRest {
108
108
 
109
109
  if (col?.schema) {
110
110
  let schema = col.schema as Schema;
111
+ schema = schema;
111
112
 
112
113
  if (options.partial) {
113
114
  let partialSchema = schema.fork(
@@ -116,9 +117,13 @@ class useRest {
116
117
  return sc.optional();
117
118
  }
118
119
  );
119
- control = partialSchema.validate(data) as any;
120
+ control = partialSchema.validate(data, {
121
+ allowUnknown: false,
122
+ }) as any;
120
123
  } else {
121
- control = schema.validate(data) as any;
124
+ control = schema.validate(data, {
125
+ allowUnknown: false,
126
+ }) as any;
122
127
  }
123
128
 
124
129
  const { error, value } = control;
@@ -375,7 +375,24 @@ function formatData(
375
375
  return data;
376
376
  }
377
377
 
378
+ function removeKeysAtFirstLevel(data: any, keysToRemove: string[]) {
379
+ if (Array.isArray(data)) {
380
+ return data.map((item) => removeKeys(item, keysToRemove));
381
+ } else {
382
+ return removeKeys(data, keysToRemove);
383
+ }
384
+ }
385
+
386
+ function removeKeys(obj: object, keysToRemove: string[]) {
387
+ const newObj = { ...obj };
388
+ keysToRemove.forEach((key) => {
389
+ delete newObj[key];
390
+ });
391
+ return newObj;
392
+ }
393
+
378
394
  export {
395
+ removeKeysAtFirstLevel,
379
396
  buildPipeline,
380
397
  deepSetId,
381
398
  toBson,
package/lib/collection.ts CHANGED
@@ -226,6 +226,14 @@ async function syncCollectionDatabase() {
226
226
  }
227
227
  }
228
228
 
229
+ function getKeyFields(col: Collection) {
230
+ let keyFields: string[] = [];
231
+ col?.fields?.map((f) => {
232
+ keyFields.push(f.name);
233
+ });
234
+ return keyFields;
235
+ }
236
+
229
237
  export {
230
238
  loadAllCollections,
231
239
  getCollection,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dnax/core",
3
- "version": "0.8.10",
3
+ "version": "0.8.11",
4
4
  "module": "index.ts",
5
5
  "type": "module",
6
6
  "bin": {