fix(plugin-workflow-aggregate): limit aggregate instruction to only work on db data source (#5033)

This commit is contained in:
Junyi 2024-08-10 11:32:58 +08:00 committed by GitHub
parent 70bb95bcaf
commit 65ec69cc62
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 0 deletions

View File

@ -238,6 +238,11 @@ export default class extends Instruction {
required: true,
'x-decorator': 'FormItem',
'x-component': 'DataSourceCollectionCascader',
'x-component-props': {
dataSourceFilter(datasource) {
return datasource.key === 'main' || datasource.options.isDBInstance;
},
},
title: `{{t("Data of collection", { ns: "${NAMESPACE}" })}}`,
'x-reactions': [
{

View File

@ -25,6 +25,10 @@ export default class extends Instruction {
const options = processor.getParsedValue(params, node.id);
const [dataSourceName, collectionName] = parseCollectionName(collection);
const { collectionManager } = this.workflow.app.dataSourceManager.dataSources.get(dataSourceName);
// @ts-ignore
if (!collectionManager.db) {
throw new Error('aggregate instruction can only work with data source of type database');
}
const repo = associated
? collectionManager.getRepository(
`${association?.associatedCollection}.${association.name}`,