From 79d2647c5162c6528abff4d9a7f433221be6365e Mon Sep 17 00:00:00 2001 From: ChengLei Shao Date: Wed, 29 Nov 2023 14:09:22 +0800 Subject: [PATCH] chore: sync collection after set collection fields (#3112) --- .../src/server/resourcers/collections.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/packages/plugins/@nocobase/plugin-collection-manager/src/server/resourcers/collections.ts b/packages/plugins/@nocobase/plugin-collection-manager/src/server/resourcers/collections.ts index 66bc2749d..f738816a8 100644 --- a/packages/plugins/@nocobase/plugin-collection-manager/src/server/resourcers/collections.ts +++ b/packages/plugins/@nocobase/plugin-collection-manager/src/server/resourcers/collections.ts @@ -14,14 +14,14 @@ export default { const db = ctx.app.db as Database; - const collection = await db.getRepository('collections').findOne({ + const collectionModel = await db.getRepository('collections').findOne({ filter: { name: filterByTk, }, transaction, }); - const existFields = await collection.getFields({ + const existFields = await collectionModel.getFields({ transaction, }); @@ -65,10 +65,19 @@ export default { }); } - await collection.loadFields({ + await collectionModel.loadFields({ transaction, }); + const collection = db.getCollection(filterByTk); + await collection.sync({ + force: false, + alter: { + drop: false, + }, + transaction, + } as any); + await transaction.commit(); } catch (e) { await transaction.rollback();