Libraries
    Preparing search index...
    • Wrap an ObjectSchemaBuilder in an Entity, enabling typed relation declaration via .hasOne() / .hasMany() / .belongsTo() / .belongsToMany().

      Type Parameters

      • TSchema extends ObjectSchemaBuilder<any, any, any, any, any, any, any>

      Parameters

      Returns Entity<TSchema, {}>

      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);