mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-10 20:35:02 +00:00
feat: upgrade to TypeORM 0.3
This commit is contained in:
parent
8cee4ec1e4
commit
761ff27771
57 changed files with 412 additions and 325 deletions
|
@ -1,6 +1,6 @@
|
|||
import { getRepository, Repository } from "typeorm/index";
|
||||
import { Repository } from "typeorm/index";
|
||||
import { BaseGuildRepository } from "./BaseGuildRepository";
|
||||
import { connection } from "./db";
|
||||
import { dataSource } from "./dataSource";
|
||||
import { MemberTimezone } from "./entities/MemberTimezone";
|
||||
|
||||
export class GuildMemberTimezones extends BaseGuildRepository {
|
||||
|
@ -8,22 +8,26 @@ export class GuildMemberTimezones extends BaseGuildRepository {
|
|||
|
||||
constructor(guildId: string) {
|
||||
super(guildId);
|
||||
this.memberTimezones = getRepository(MemberTimezone);
|
||||
this.memberTimezones = dataSource.getRepository(MemberTimezone);
|
||||
}
|
||||
|
||||
get(memberId: string) {
|
||||
return this.memberTimezones.findOne({
|
||||
guild_id: this.guildId,
|
||||
member_id: memberId,
|
||||
where: {
|
||||
guild_id: this.guildId,
|
||||
member_id: memberId,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async set(memberId, timezone: string) {
|
||||
await connection.transaction(async (entityManager) => {
|
||||
await dataSource.transaction(async (entityManager) => {
|
||||
const repo = entityManager.getRepository(MemberTimezone);
|
||||
const existingRow = await repo.findOne({
|
||||
guild_id: this.guildId,
|
||||
member_id: memberId,
|
||||
where: {
|
||||
guild_id: this.guildId,
|
||||
member_id: memberId,
|
||||
},
|
||||
});
|
||||
|
||||
if (existingRow) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue