3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-21 16:55:03 +00:00

Split BaseRepository into non-guild and guild

BaseRepository includes all the non-guild-specific functionality,
such as with() and getRelations().
BaseGuildRepository includes guild-specific functionality, such as
getInstance().
This commit is contained in:
Dragory 2019-05-25 21:25:34 +03:00
parent ad9b4a63b7
commit 9109e9a2c3
39 changed files with 162 additions and 156 deletions

View file

@ -1,22 +1,21 @@
import { BaseRepository } from "./BaseRepository";
import { getRepository, Repository } from "typeorm";
import { UsernameHistoryEntry } from "./entities/UsernameHistoryEntry";
import { sorter } from "../utils";
import { BaseRepository } from "./BaseRepository";
export const MAX_USERNAME_ENTRIES_PER_USER = 10;
export class UsernameHistory extends BaseRepository {
private usernameHistory: Repository<UsernameHistoryEntry>;
constructor(guildId) {
super(guildId);
constructor() {
super();
this.usernameHistory = getRepository(UsernameHistoryEntry);
}
async getByUserId(userId): Promise<UsernameHistoryEntry[]> {
return this.usernameHistory.find({
where: {
guild_id: this.guildId,
user_id: userId,
},
order: {
@ -29,7 +28,6 @@ export class UsernameHistory extends BaseRepository {
getLastEntry(userId): Promise<UsernameHistoryEntry> {
return this.usernameHistory.findOne({
where: {
guild_id: this.guildId,
user_id: userId,
},
order: {