More types
This commit is contained in:
parent
f3762885c6
commit
1e8aa9eb60
|
@ -7,6 +7,7 @@ import LinkDocument from "./LinkDocument"
|
||||||
import {
|
import {
|
||||||
Database,
|
Database,
|
||||||
FieldSchema,
|
FieldSchema,
|
||||||
|
FieldType,
|
||||||
LinkDocumentValue,
|
LinkDocumentValue,
|
||||||
RelationshipFieldMetadata,
|
RelationshipFieldMetadata,
|
||||||
RelationshipType,
|
RelationshipType,
|
||||||
|
@ -187,9 +188,7 @@ class LinkController {
|
||||||
|
|
||||||
// if 1:N, ensure that this ID is not already attached to another record
|
// if 1:N, ensure that this ID is not already attached to another record
|
||||||
const linkedTable = await this._db.get<Table>(field.tableId)
|
const linkedTable = await this._db.get<Table>(field.tableId)
|
||||||
const linkedSchema = linkedTable.schema[
|
const linkedSchema = linkedTable.schema[field.fieldName]
|
||||||
field.fieldName!
|
|
||||||
] as RelationshipFieldMetadata
|
|
||||||
|
|
||||||
// We need to map the global users to metadata in each app for relationships
|
// We need to map the global users to metadata in each app for relationships
|
||||||
if (field.tableId === InternalTables.USER_METADATA) {
|
if (field.tableId === InternalTables.USER_METADATA) {
|
||||||
|
@ -206,7 +205,10 @@ class LinkController {
|
||||||
|
|
||||||
// iterate through the link IDs in the row field, see if any don't exist already
|
// iterate through the link IDs in the row field, see if any don't exist already
|
||||||
for (let linkId of rowField) {
|
for (let linkId of rowField) {
|
||||||
if (linkedSchema?.relationshipType === RelationshipType.ONE_TO_MANY) {
|
if (
|
||||||
|
linkedSchema?.type === FieldType.LINK &&
|
||||||
|
linkedSchema?.relationshipType === RelationshipType.ONE_TO_MANY
|
||||||
|
) {
|
||||||
let links = (
|
let links = (
|
||||||
(await getLinkDocuments({
|
(await getLinkDocuments({
|
||||||
tableId: field.tableId,
|
tableId: field.tableId,
|
||||||
|
@ -359,7 +361,7 @@ class LinkController {
|
||||||
// these are the props of the table that initiated the link
|
// these are the props of the table that initiated the link
|
||||||
tableId: table._id!,
|
tableId: table._id!,
|
||||||
fieldName: fieldName,
|
fieldName: fieldName,
|
||||||
} as any)
|
} as RelationshipFieldMetadata)
|
||||||
|
|
||||||
// update table schema after checking relationship types
|
// update table schema after checking relationship types
|
||||||
schema[fieldName] = fields.linkerField
|
schema[fieldName] = fields.linkerField
|
||||||
|
|
Loading…
Reference in New Issue