2019-05-26 00:13:42 +03:00
|
|
|
import { getRepository, Repository } from "typeorm";
|
2019-06-23 19:18:41 +03:00
|
|
|
import { ApiPermission } from "./entities/ApiPermission";
|
2019-05-26 00:13:42 +03:00
|
|
|
import { BaseRepository } from "./BaseRepository";
|
|
|
|
|
2019-06-23 19:18:41 +03:00
|
|
|
export class ApiPermissions extends BaseRepository {
|
|
|
|
private apiPermissions: Repository<ApiPermission>;
|
2019-05-26 00:13:42 +03:00
|
|
|
|
|
|
|
constructor() {
|
|
|
|
super();
|
2019-06-23 19:18:41 +03:00
|
|
|
this.apiPermissions = getRepository(ApiPermission);
|
2019-05-26 00:13:42 +03:00
|
|
|
}
|
2019-06-23 03:40:53 +03:00
|
|
|
|
2019-07-22 00:11:24 +03:00
|
|
|
getByUserId(userId) {
|
|
|
|
return this.apiPermissions.find({
|
|
|
|
where: {
|
|
|
|
user_id: userId,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-06-23 03:40:53 +03:00
|
|
|
getByGuildAndUserId(guildId, userId) {
|
2019-06-23 19:18:41 +03:00
|
|
|
return this.apiPermissions.findOne({
|
2019-06-23 03:40:53 +03:00
|
|
|
where: {
|
|
|
|
guild_id: guildId,
|
|
|
|
user_id: userId,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
2019-05-26 00:13:42 +03:00
|
|
|
}
|