mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-05 21:13:37 +00:00
30 lines
872 B
TypeScript
30 lines
872 B
TypeScript
import { BaseRepository } from "@edr/api-common";
|
|
import { Injectable } from "@nestjs/common";
|
|
import { InjectRepository } from "@nestjs/typeorm";
|
|
import { Repository } from "typeorm";
|
|
|
|
import { Publication } from "./entities/publication.entity";
|
|
|
|
@Injectable()
|
|
export class PublicationsRepository extends BaseRepository<Publication> {
|
|
constructor(
|
|
@InjectRepository(Publication)
|
|
repository: Repository<Publication>,
|
|
) {
|
|
super(repository);
|
|
}
|
|
|
|
/** Public list: published rows only, in display order. */
|
|
findPublished(): Promise<Publication[]> {
|
|
return this.repository.find({
|
|
where: { published: true },
|
|
order: { sortOrder: "ASC", publishedAt: "DESC" },
|
|
});
|
|
}
|
|
|
|
/** Admin list: every row, published or not. */
|
|
override findAll(): Promise<Publication[]> {
|
|
return this.repository.find({ order: { sortOrder: "ASC" } });
|
|
}
|
|
}
|