egon-orm-workspace / egon-orm / Assoc
Interface: Assoc<K, T, FK> ​
Defined in: core/src/contracts/schema.ts:816
An association declaration: what hasMany(() => Post) and its siblings return, held in a static member of the owner class (decision D1). K is the kind and T the target class. FK is the foreign-key field name (or names) when it was given as a literal, and undefined when the default name applies; Loaded uses it to decide whether a preloaded belongsTo can be null.
Example ​
declare function hasMany<T>(target: () => T): Assoc<"hasMany", T, undefined>;
declare const Post: AnySchema;
const posts = hasMany(() => Post); // Assoc<"hasMany", typeof Post, undefined>Type Parameters ​
K ​
K extends AssocKind = AssocKind
T ​
T = unknown
FK ​
FK extends string | readonly string[] | undefined = string | readonly string[] | undefined
Properties ​
~foreignKey? ​
readonly "~foreignKey"?: FK;Defined in: core/src/contracts/schema.ts:825
Type-level only; never set at runtime.
kind ​
readonly kind: K;Defined in: core/src/contracts/schema.ts:821
target ​
readonly target: () => T;Defined in: core/src/contracts/schema.ts:823
The thunk given at declaration; called lazily, so circular associations work.
Returns ​
T

