Fix relationship field metadata

This commit is contained in:
Adria Navarro 2023-10-11 12:55:23 +02:00
parent 5edc3d3de6
commit 248c44ac2a
2 changed files with 22 additions and 9 deletions

View File

@ -54,6 +54,7 @@ import {
FieldType,
RelationshipType,
CreateViewRequest,
RelationshipFieldMetadata,
} from "@budibase/types"
import API from "./api"
@ -587,7 +588,7 @@ class TestConfiguration {
tableId: this.table._id!,
name: link,
relationshipType,
}
} as RelationshipFieldMetadata
}
if (this.datasource && !tableConfig.sourceId) {

View File

@ -19,17 +19,29 @@ interface BaseRelationshipFieldMetadata
extends Omit<BaseFieldSchema, "subtype"> {
type: FieldType.LINK
main?: boolean
fieldName?: string
fieldName: string
tableId: string
subtype?: Omit<AutoFieldSubTypes, AutoFieldSubTypes.AUTO_ID>
}
export interface ManyToManyRelationshipFieldMetadata
extends BaseRelationshipFieldMetadata {
relationshipType: RelationshipType.MANY_TO_MANY
through?: string
throughFrom?: string
throughTo?: string
}
// External tables use junction tables, internal tables don't require them
type ManyToManyJunctionTableMetadata =
| {
through: string
throughFrom: string
throughTo: string
}
| {
through?: never
throughFrom?: never
throughTo?: never
}
export type ManyToManyRelationshipFieldMetadata =
BaseRelationshipFieldMetadata & {
relationshipType: RelationshipType.MANY_TO_MANY
} & ManyToManyJunctionTableMetadata
export interface OneToManyRelationshipFieldMetadata
extends BaseRelationshipFieldMetadata {
relationshipType: RelationshipType.ONE_TO_MANY