Răsfoiți Sursa

insert null to pages documents that has parent field

yohei0125 4 ani în urmă
părinte
comite
7a96c613af

+ 0 - 2
packages/app/src/server/models/page.ts

@@ -31,8 +31,6 @@ const PAGE_GRANT_ERROR = 1;
 const STATUS_PUBLISHED = 'published';
 const STATUS_DELETED = 'deleted';
 
-export const OVERWRITE_PERMITTED_PAGES_FIELDS = ['parent'];
-
 export interface PageDocument extends IPage, Document {}
 
 

+ 1 - 2
packages/app/src/server/routes/apiv3/overwrite-params/pages.js

@@ -42,8 +42,7 @@ class PageOverwriteParamsFactory {
     };
 
     params.parent = (value, { document, schema, propertyName }) => {
-      if (value === undefined) return null;
-      return value;
+      return null;
     };
 
     if (option.initPageMetadatas) {

+ 1 - 12
packages/app/src/server/service/import.js

@@ -16,20 +16,12 @@ const mongoose = require('mongoose');
 
 const { ObjectId } = mongoose.Types;
 
-const { OVERWRITE_PERMITTED_PAGES_FIELDS } = require('../../server/models/page');
-
 const { createBatchStream } = require('../util/batch-stream');
 const CollectionProgressingStatus = require('../models/vo/collection-progressing-status');
 
 
 const BULK_IMPORT_SIZE = 100;
 
-// map collection name to fields that don't exist or are undefined but are permitted to be overwritten
-const OVERWRITE_PERMITTED_FIELD_MAP = {
-  pages: OVERWRITE_PERMITTED_PAGES_FIELDS,
-};
-
-
 class ImportSettings {
 
   constructor(mode) {
@@ -481,10 +473,7 @@ class ImportService {
     Object.entries(overwriteParams).forEach(([propertyName, overwriteValue]) => {
       const value = document[propertyName];
 
-      // check if the field does not exist or is undefined but it's permitted to be overwritten
-      const isOverwritePermittedValue = OVERWRITE_PERMITTED_FIELD_MAP[collectionName].includes(propertyName);
-
-      if (value !== undefined || isOverwritePermittedValue) {
+      if (value !== undefined) {
         const overwriteFunc = (typeof overwriteValue === 'function') ? overwriteValue : null;
         _document[propertyName] = (overwriteFunc != null) ? overwriteFunc(value, { document: _document, propertyName, schema }) : overwriteValue;
       }