@dnax/core 0.64.4 → 0.64.6

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.
@@ -241,6 +241,22 @@ function toBson<T>(
241
241
  function deepSetId(col: Collection, data: any) {
242
242
  if (col) {
243
243
  col?.fields?.map((f) => {
244
+ if (f?.type?.match(/(json|array)/) && data[f?.name]) {
245
+ if (f?.injectAutoId && f?.type == "array") {
246
+ data[f.name]?.map((d, index) => {
247
+ if (!d?._id) {
248
+ d._id = String(new ObjectId());
249
+ }
250
+ });
251
+ }
252
+
253
+ if (f?.injectAutoId && f?.type == "json") {
254
+ if (!data[f.name]?._id) {
255
+ data[f.name]._id = String(new ObjectId());
256
+ }
257
+ }
258
+ }
259
+
244
260
  if (f?.type?.match(/(relationship|media)/) && data[f.name]) {
245
261
  if (typeof data[f.name] == "object" && !Array.isArray(data[f.name])) {
246
262
  data[f.name] = data[f.name]?._id || data[f.name]?.id || data[f.name];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dnax/core",
3
- "version": "0.64.4",
3
+ "version": "0.64.6",
4
4
  "module": "index.ts",
5
5
  "type": "module",
6
6
  "bin": {
package/types/index.ts CHANGED
@@ -41,7 +41,6 @@ export type Tenant = {
41
41
  enabled?: boolean;
42
42
  host: string;
43
43
  apiKey: string;
44
-
45
44
  client?: InstanceType<typeof import("meilisearch").MeiliSearch>;
46
45
  };
47
46
  };
@@ -135,6 +134,10 @@ export type Field = {
135
134
  to: string; // collection name
136
135
  hasMany?: boolean;
137
136
  };
137
+ /**
138
+ * Inject ObjectId if field type's are json or Array of json
139
+ */
140
+ injectAutoId?: boolean;
138
141
  sparse?: boolean;
139
142
  // relationType?: "ref-to-one" | "ref-to-many";
140
143
  /**