Closed avidianity closed 3 years ago
@avidianity , unfortunately I haven't extended the package to support the Active Record pattern, for now it only supports the Repository pattern. Any ideas or PRs are welcome. Thanks.
@avidianity and anyone still interested in how to use Pagination with the Active Record Pattern, I revisited this. The package supports AR pagination out of the box. Since pagination is built as an extension of the SelectQuerybuilder interface, here is how to achieve this:
Your Entity
@Entity()
export class UserType extends BaseEntity {
@PrimaryGeneratedColumn()
id: number;
@Column({
unique: true,
type: String
})
slug: string;
@Column({
unique: true,
type: String
})
name: string;
@OneToMany(type => User, user => user.type)
users: User[]
}
Paginate using AR
return await UserType.createQueryBuilder().paginate();
I have a Statement entity.
How do I paginate this? Something like
Statement.paginate()
would be great.