Wrap an ObjectSchemaBuilder in an Entity, enabling typed relation declaration via .hasOne() / .hasMany() / .belongsTo() / .belongsToMany().
ObjectSchemaBuilder
.hasOne()
.hasMany()
.belongsTo()
.belongsToMany()
const UserEntity = defineEntity( object({ id: number().primaryKey(), name: string(), posts: array(PostEntity.schema) }).hasTableName('users')).hasMany(t => t.posts, l => l.id, r => r.userId); Copy
const UserEntity = defineEntity( object({ id: number().primaryKey(), name: string(), posts: array(PostEntity.schema) }).hasTableName('users')).hasMany(t => t.posts, l => l.id, r => r.userId);
Wrap an
ObjectSchemaBuilderin an Entity, enabling typed relation declaration via.hasOne()/.hasMany()/.belongsTo()/.belongsToMany().