mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-10 12:25:02 +00:00
Reorganize project. Add folder for shared code between backend/dashboard. Switch from jest to ava for tests.
This commit is contained in:
parent
80a82fe348
commit
16111bbe84
162 changed files with 11056 additions and 9900 deletions
41
backend/src/data/GuildScheduledPosts.ts
Normal file
41
backend/src/data/GuildScheduledPosts.ts
Normal file
|
@ -0,0 +1,41 @@
|
|||
import { BaseGuildRepository } from "./BaseGuildRepository";
|
||||
import { getRepository, Repository } from "typeorm";
|
||||
import { ScheduledPost } from "./entities/ScheduledPost";
|
||||
|
||||
export class GuildScheduledPosts extends BaseGuildRepository {
|
||||
private scheduledPosts: Repository<ScheduledPost>;
|
||||
|
||||
constructor(guildId) {
|
||||
super(guildId);
|
||||
this.scheduledPosts = getRepository(ScheduledPost);
|
||||
}
|
||||
|
||||
all(): Promise<ScheduledPost[]> {
|
||||
return this.scheduledPosts
|
||||
.createQueryBuilder()
|
||||
.where("guild_id = :guildId", { guildId: this.guildId })
|
||||
.getMany();
|
||||
}
|
||||
|
||||
getDueScheduledPosts(): Promise<ScheduledPost[]> {
|
||||
return this.scheduledPosts
|
||||
.createQueryBuilder()
|
||||
.where("guild_id = :guildId", { guildId: this.guildId })
|
||||
.andWhere("post_at <= NOW()")
|
||||
.getMany();
|
||||
}
|
||||
|
||||
async delete(id) {
|
||||
await this.scheduledPosts.delete({
|
||||
guild_id: this.guildId,
|
||||
id,
|
||||
});
|
||||
}
|
||||
|
||||
async create(data: Partial<ScheduledPost>) {
|
||||
await this.scheduledPosts.insert({
|
||||
...data,
|
||||
guild_id: this.guildId,
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue