egon-orm-workspace / egon-orm / Loaded
Type Alias: Loaded<S, P> ​
ts
type Loaded<S, P> = LoadedUnchecked<S, P>;Defined in: core/src/contracts/schema.ts:962
A row of schema S with the associations in P loaded: Row plus one property per loaded association, to any depth.
hasManyandmanyToManybecome an array of the target's rows.hasOnebecomes the target's row ornull.belongsTobecomes the target's row, or| nullwhen the foreign-key field is nullable. The foreign key is theforeignKeygiven tobelongsTo, by default<association name>Id; when it cannot be determined the result is| null.
Type Parameters ​
S ​
S extends AnySchema
P ​
P extends PreloadSpec<S>
Example ​
ts
declare const Comment: AnySchema;
declare const Post: AnySchema & { comments: Assoc<"hasMany", typeof Comment> };
declare const User: AnySchema & { posts: Assoc<"hasMany", typeof Post> };
declare const user: Loaded<typeof User, { posts: "comments" }>;
user.posts[0]?.comments; // Row<typeof Comment>[] | undefined
