1
0
Fork 0
mirror of synced 2024-10-02 18:16:29 +13:00

Set the relationship type (#12275)

* Set the relationship type

* Add users type

* Set user relationship type saveColumn

* Set relationshipType for users type on save

* Add relatioshipType to schema

* Refactor

* Check isUsersColumn

* Make relationshipType optional

---------

Co-authored-by: Michael Drury <me@michaeldrury.co.uk>
This commit is contained in:
melohagan 2023-11-07 11:59:51 +00:00 committed by GitHub
parent 958af2677c
commit f28eb054f3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 0 deletions

View file

@ -44,6 +44,8 @@
const NUMBER_TYPE = FIELDS.NUMBER.type
const JSON_TYPE = FIELDS.JSON.type
const DATE_TYPE = FIELDS.DATETIME.type
const USER_TYPE = FIELDS.USER.subtype
const USERS_TYPE = FIELDS.USERS.subtype
const dispatch = createEventDispatcher()
const PROHIBITED_COLUMN_NAMES = ["type", "_id", "_rev", "tableId"]
@ -287,6 +289,14 @@
if (saveColumn.type !== LINK_TYPE) {
delete saveColumn.fieldName
}
if (isUsersColumn(saveColumn)) {
if (saveColumn.subtype === USER_TYPE) {
saveColumn.relationshipType = RelationshipType.ONE_TO_MANY
} else if (saveColumn.subtype === USERS_TYPE) {
saveColumn.relationshipType = RelationshipType.MANY_TO_MANY
}
}
try {
await tables.saveField({
originalName,

View file

@ -102,6 +102,7 @@ export interface BBReferenceFieldMetadata
extends Omit<BaseFieldSchema, "subtype"> {
type: FieldType.BB_REFERENCE
subtype: FieldSubtype.USER | FieldSubtype.USERS
relationshipType?: RelationshipType
}
export interface FieldConstraints {