Libraries v5.0.0
    Preparing search index...

    Type Alias WithRelation<TSchema, TRels, TKey, TKind, TForeign, TVariantUnion, TReadVariants>

    WithRelation: Entity<
        TSchema,
        TRels & {
            -readonly [P in keyof Pick<
                SchemaProps<TSchema>,
                Extract<TKey, keyof SchemaProps<TSchema>>,
            >]-?: RelationInfo<TKind, TForeign>
        } & Record<
            Exclude<TKey, keyof SchemaProps<TSchema>>,
            RelationInfo<TKind, TForeign>,
        >,
        TVariantUnion,
        TReadVariants,
    >

    Return type for an Entity method that adds a relation: keeps TSchema, extends TRels with one more entry, and preserves TVariantUnion.

    Type Parameters

    • TSchema extends ObjectSchemaBuilder<any, any, any, any, any, any, any>
    • TRels extends Record<string, RelationInfo>
    • TKey extends string
    • TKind extends "belongsTo" | "hasOne" | "hasMany" | "belongsToMany"
    • TForeign extends ObjectSchemaBuilder<any, any, any, any, any, any, any>
    • TVariantUnion = never
    • TReadVariants extends ReadVariants = {}