Yuki Takei 1 год назад
Родитель
Сommit
09875c7ffe
1 измененных файлов с 6 добавлено и 0 удалено
  1. 6 0
      apps/app/src/server/service/import/overwrite-function.ts

+ 6 - 0
apps/app/src/server/service/import/overwrite-function.ts

@@ -24,6 +24,12 @@ export const keepOriginal: OverwriteFunction = (value, { document, schema, prope
   // Model
   // Model
   if (schema != null && schema.path(propertyName) != null) {
   if (schema != null && schema.path(propertyName) != null) {
     const schemaType = schema.path(propertyName);
     const schemaType = schema.path(propertyName);
+
+    // force to set schema to the document
+    //  cz: SchemaArray.cast requires the document to have 'schema' property
+    // ref: https://github.com/Automattic/mongoose/blob/6.11.4/lib/schema/array.js#L334
+    document.schema = schema;
+
     return schemaType.cast(value, document, true);
     return schemaType.cast(value, document, true);
   }
   }