jp.db.schemas 2.1.15 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/dist/index.d.ts +6 -4
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +6 -1
  4. package/dist/index.js.map +1 -1
  5. package/dist/repositories/index.d.ts +2 -1
  6. package/dist/repositories/index.d.ts.map +1 -1
  7. package/dist/repositories/index.js +3 -1
  8. package/dist/repositories/index.js.map +1 -1
  9. package/dist/repositories/setting.repository.d.ts +1 -1
  10. package/dist/repositories/setting.repository.d.ts.map +1 -1
  11. package/dist/repositories/setting.repository.js +1 -1
  12. package/dist/repositories/setting.repository.js.map +1 -1
  13. package/dist/repositories/settings-options.repository.d.ts +8 -0
  14. package/dist/repositories/settings-options.repository.d.ts.map +1 -0
  15. package/dist/repositories/settings-options.repository.js +39 -0
  16. package/dist/repositories/settings-options.repository.js.map +1 -0
  17. package/dist/repositories/welcome.repository.d.ts +1 -1
  18. package/dist/repositories/welcome.repository.d.ts.map +1 -1
  19. package/dist/repositories/welcome.repository.js +2 -2
  20. package/dist/repositories/welcome.repository.js.map +1 -1
  21. package/dist/schemas/product.schema.d.ts +20 -0
  22. package/dist/schemas/product.schema.d.ts.map +1 -1
  23. package/dist/schemas/product.schema.js +8 -0
  24. package/dist/schemas/product.schema.js.map +1 -1
  25. package/dist/schemas/setting.schema.d.ts +10 -40
  26. package/dist/schemas/setting.schema.d.ts.map +1 -1
  27. package/dist/schemas/setting.schema.js +9 -21
  28. package/dist/schemas/setting.schema.js.map +1 -1
  29. package/dist/schemas/settings_option.schema.d.ts +105 -0
  30. package/dist/schemas/settings_option.schema.d.ts.map +1 -0
  31. package/dist/schemas/settings_option.schema.js +57 -0
  32. package/dist/schemas/settings_option.schema.js.map +1 -0
  33. package/package.json +31 -31
  34. package/readme.md +3 -3
  35. package/src/index.ts +257 -251
  36. package/src/models/activity-log-user-login.interface copy.ts +9 -9
  37. package/src/models/activity-log-user-login.interface.ts +9 -9
  38. package/src/models/activity-log.enum.ts +7 -7
  39. package/src/models/currency.enum.ts +4 -4
  40. package/src/models/rating-add-bulk-item.interface.ts +6 -6
  41. package/src/models/rating-monthly-result.interface.ts +10 -10
  42. package/src/models/tournament-participant.interface.ts +5 -5
  43. package/src/models/tournament-status.enum.ts +6 -6
  44. package/src/models/tournament-template.enum.ts +3 -3
  45. package/src/models/tournament-winner.interface.ts +7 -7
  46. package/src/repositories/achievement.repository.ts +18 -18
  47. package/src/repositories/activity-log.repository.ts +110 -110
  48. package/src/repositories/admin.repository.ts +23 -23
  49. package/src/repositories/article.repository.ts +33 -33
  50. package/src/repositories/balance-history.repository.ts +15 -15
  51. package/src/repositories/banners.repository.ts +54 -54
  52. package/src/repositories/complains.repository.ts +30 -30
  53. package/src/repositories/daily-bonus.repository.ts +25 -25
  54. package/src/repositories/friend.repository.ts +19 -19
  55. package/src/repositories/game-result.repository.ts +15 -15
  56. package/src/repositories/game-statistic.repository.ts +21 -21
  57. package/src/repositories/index.ts +59 -57
  58. package/src/repositories/menu.repository.ts +21 -21
  59. package/src/repositories/notification.repository.ts +54 -54
  60. package/src/repositories/premium.repository.ts +17 -17
  61. package/src/repositories/products.repository.ts +29 -29
  62. package/src/repositories/purchase.repository.ts +95 -95
  63. package/src/repositories/rating.repository.ts +83 -83
  64. package/src/repositories/rooms.repository.ts +17 -17
  65. package/src/repositories/rule.repository.ts +17 -17
  66. package/src/repositories/scheduled-tournaments.repository.ts +30 -30
  67. package/src/repositories/servers.repository.ts +18 -18
  68. package/src/repositories/setting.repository.ts +19 -19
  69. package/src/repositories/settings-options.repository.ts +20 -0
  70. package/src/repositories/simple-rooms.repository.ts +17 -17
  71. package/src/repositories/tournament-many-tables-rooms.repository.ts +132 -132
  72. package/src/repositories/tournament-one-table-rooms.repository.ts +106 -106
  73. package/src/repositories/users.repository.ts +151 -151
  74. package/src/repositories/welcome.repository.ts +17 -17
  75. package/src/schemas/achievement.schema.ts +40 -40
  76. package/src/schemas/activity_log.schema.ts +37 -37
  77. package/src/schemas/admin.schema.ts +22 -22
  78. package/src/schemas/article.schema.ts +37 -37
  79. package/src/schemas/balance_history.schema.ts +37 -37
  80. package/src/schemas/banner.schema.ts +40 -40
  81. package/src/schemas/channel_message.schema.ts +31 -31
  82. package/src/schemas/complain.schema.ts +46 -46
  83. package/src/schemas/daily_bonus.schema.ts +56 -56
  84. package/src/schemas/feature.schema.ts +28 -28
  85. package/src/schemas/friend.schema.ts +50 -50
  86. package/src/schemas/game_result.schema.ts +68 -68
  87. package/src/schemas/game_statistic.schema.ts +40 -40
  88. package/src/schemas/menu.schema.ts +40 -40
  89. package/src/schemas/notification.schema.ts +61 -61
  90. package/src/schemas/premium.schema.ts +45 -45
  91. package/src/schemas/product.schema.ts +129 -123
  92. package/src/schemas/purchase.schema.ts +58 -58
  93. package/src/schemas/purchase_channel.schema.ts +31 -31
  94. package/src/schemas/rating.schema.ts +37 -37
  95. package/src/schemas/rooms.schema.ts +63 -63
  96. package/src/schemas/rule.schema.ts +45 -45
  97. package/src/schemas/scheduled_tournament.schema.ts +93 -93
  98. package/src/schemas/server.schema.ts +22 -22
  99. package/src/schemas/setting.schema.ts +46 -55
  100. package/src/schemas/settings_option.schema.ts +37 -0
  101. package/src/schemas/simple_rooms.schema.ts +46 -46
  102. package/src/schemas/tournament_many_tables_rooms.schema.ts +84 -84
  103. package/src/schemas/tournament_one_table_rooms.schema.ts +81 -81
  104. package/src/schemas/user.fb.schema.ts +33 -33
  105. package/src/schemas/user.google.schema.ts +24 -24
  106. package/src/schemas/user.ok.schema.ts +52 -52
  107. package/src/schemas/user.schema.ts +182 -182
  108. package/src/schemas/user.tg.schema.ts +30 -30
  109. package/src/schemas/user.vk.schema.ts +70 -70
  110. package/src/schemas/user.ya.schema.ts +24 -24
  111. package/src/schemas/welcome.schema.ts +45 -45
  112. package/src/utils.ts +3 -3
@@ -1,7 +1,7 @@
1
- export interface ITournamentWinner {
2
- playerId: string;
3
- playerName: string;
4
- playerAvatarUrl: string;
5
- profit: number;
6
- rank: number;
7
- }
1
+ export interface ITournamentWinner {
2
+ playerId: string;
3
+ playerName: string;
4
+ playerAvatarUrl: string;
5
+ profit: number;
6
+ rank: number;
7
+ }
@@ -1,18 +1,18 @@
1
- import { Injectable } from '@nestjs/common';
2
- import { InjectModel } from '@nestjs/mongoose';
3
- import { Model } from 'mongoose';
4
-
5
- import { Achievement, AchievementDocument } from '..';
6
-
7
- @Injectable()
8
- export class AchievementRepository {
9
- constructor (@InjectModel(Achievement.name) private menuModel: Model<AchievementDocument>) {
10
- }
11
-
12
- async findAchievements (): Promise<Array<Achievement>> {
13
- return this.menuModel
14
- .find()
15
- .exec();
16
- }
17
- }
18
-
1
+ import { Injectable } from '@nestjs/common';
2
+ import { InjectModel } from '@nestjs/mongoose';
3
+ import { Model } from 'mongoose';
4
+
5
+ import { Achievement, AchievementDocument } from '..';
6
+
7
+ @Injectable()
8
+ export class AchievementRepository {
9
+ constructor (@InjectModel(Achievement.name) private menuModel: Model<AchievementDocument>) {
10
+ }
11
+
12
+ async findAchievements (): Promise<Array<Achievement>> {
13
+ return this.menuModel
14
+ .find()
15
+ .exec();
16
+ }
17
+ }
18
+
@@ -1,110 +1,110 @@
1
- import { Injectable } from '@nestjs/common';
2
- import { InjectModel } from '@nestjs/mongoose';
3
- import { Model } from 'mongoose';
4
- import dayjs from 'dayjs';
5
-
6
- import { ActivityLog, ActivityLogDocument } from '..';
7
- import { ActivityLogEnum } from '../models/activity-log.enum';
8
- import { IActivityLogUserLogin } from '../models/activity-log-user-login.interface';
9
-
10
- @Injectable()
11
- export class ActivityLogRepository {
12
- constructor(
13
- @InjectModel(ActivityLog.name) private activityLogModel: Model<ActivityLogDocument>
14
- ) {
15
- }
16
-
17
- async findLast7DaysLogins(
18
- game: string,
19
- userId: string,
20
- ): Promise<Array<IActivityLogUserLogin>> {
21
- const weekAgo = dayjs().startOf('day').add(-1, 'week');
22
-
23
- return this.activityLogModel.aggregate([
24
- {
25
- $match: {
26
- game,
27
- userId,
28
- date: { $gte: weekAgo.toDate() },
29
- event: ActivityLogEnum.USER_LOGIN,
30
- }
31
- },
32
- {
33
- $group: {
34
- _id: { $dateToString: { format: "%Y-%m-%d", date: "$date" } },
35
- userId: { $first: "$userId" },
36
- userName: { $first: "$userName" },
37
- event: { $first: "$event" },
38
- game: { $first: "$game" },
39
- channels: { $first: "$channels" },
40
- count: { $sum: 1 },
41
- }
42
- },
43
- {
44
- $project: {
45
- _id: 0,
46
- id: "$_id",
47
- userId: 1,
48
- userName: 1,
49
- event: 1,
50
- game: 1,
51
- channel: 1,
52
- count: 1,
53
- date: "$_id"
54
- }
55
- },
56
- {
57
- $sort: { "date": -1 }
58
- }
59
- ])
60
- }
61
-
62
- async userIsNewbie(userId: string): Promise<boolean> {
63
- return await this.activityLogModel.countDocuments({ userId, event: ActivityLogEnum.USER_LOGIN }).exec() === 1;
64
- }
65
-
66
- async getUserPlayedGamesCount(userId: string): Promise<number> {
67
- return await this.activityLogModel.countDocuments({ userId, event: ActivityLogEnum.USER_PLAYED_GAME }).exec()
68
- }
69
-
70
- async getUserWonGamesCount(userId: string): Promise<number> {
71
- return await this.activityLogModel.countDocuments({ userId, event: ActivityLogEnum.USER_WON_GAME }).exec()
72
- }
73
-
74
- async getUserWonProfiCount(userId: string): Promise<number> {
75
- return await this.activityLogModel.countDocuments({ userId, event: ActivityLogEnum.USER_WON_PROFI }).exec()
76
- }
77
-
78
- async getUserWonOneTableTournamentCount(userId: string): Promise<number> {
79
- return await this.activityLogModel.countDocuments({ userId, event: ActivityLogEnum.USER_WON_ONE_TABLE_TOURNAMENT }).exec()
80
- }
81
-
82
- async addUserLoginEvent(userId: string, userName: string, game: string, channels: string): Promise<ActivityLog> {
83
- return this.addActivityLog({ date: new Date(), event: ActivityLogEnum.USER_LOGIN, userId, userName, game, channels });
84
- }
85
-
86
- async addUserGotBonuseEvent(userId: string, userName: string, game: string, channels: string, amount: number): Promise<ActivityLog> {
87
- return this.addActivityLog({ date: new Date(), event: ActivityLogEnum.USER_GOT_BONUS, userId, userName, game, channels, amount, });
88
- }
89
-
90
- async addUserPlayedGameEvent(userId: string, userName: string, game: string, channels: string): Promise<ActivityLog> {
91
- return this.addActivityLog({ date: new Date(), event: ActivityLogEnum.USER_PLAYED_GAME, userId, userName, game, channels, });
92
- }
93
-
94
- async addUserWonGameEvent(userId: string, userName: string, game: string, channels: string): Promise<ActivityLog> {
95
- return this.addActivityLog({ date: new Date(), event: ActivityLogEnum.USER_WON_GAME, userId, userName, game, channels });
96
- }
97
-
98
- async addUserWonProfieEvent(userId: string, userName: string, game: string, channels: string): Promise<ActivityLog> {
99
- return this.addActivityLog({ date: new Date(), event: ActivityLogEnum.USER_WON_PROFI, userId, userName, game, channels });
100
- }
101
-
102
- async addUserWonOneTableTournamentEvent(userId: string, userName: string, game: string, channels: string): Promise<ActivityLog> {
103
- return this.addActivityLog({ date: new Date(), event: ActivityLogEnum.USER_WON_ONE_TABLE_TOURNAMENT, userId, userName, game, channels });
104
- }
105
-
106
- async addActivityLog(activityLog: Partial<ActivityLog>): Promise<ActivityLog> {
107
- return this.activityLogModel.create(activityLog);
108
- }
109
- }
110
-
1
+ import { Injectable } from '@nestjs/common';
2
+ import { InjectModel } from '@nestjs/mongoose';
3
+ import { Model } from 'mongoose';
4
+ import dayjs from 'dayjs';
5
+
6
+ import { ActivityLog, ActivityLogDocument } from '..';
7
+ import { ActivityLogEnum } from '../models/activity-log.enum';
8
+ import { IActivityLogUserLogin } from '../models/activity-log-user-login.interface';
9
+
10
+ @Injectable()
11
+ export class ActivityLogRepository {
12
+ constructor(
13
+ @InjectModel(ActivityLog.name) private activityLogModel: Model<ActivityLogDocument>
14
+ ) {
15
+ }
16
+
17
+ async findLast7DaysLogins(
18
+ game: string,
19
+ userId: string,
20
+ ): Promise<Array<IActivityLogUserLogin>> {
21
+ const weekAgo = dayjs().startOf('day').add(-1, 'week');
22
+
23
+ return this.activityLogModel.aggregate([
24
+ {
25
+ $match: {
26
+ game,
27
+ userId,
28
+ date: { $gte: weekAgo.toDate() },
29
+ event: ActivityLogEnum.USER_LOGIN,
30
+ }
31
+ },
32
+ {
33
+ $group: {
34
+ _id: { $dateToString: { format: "%Y-%m-%d", date: "$date" } },
35
+ userId: { $first: "$userId" },
36
+ userName: { $first: "$userName" },
37
+ event: { $first: "$event" },
38
+ game: { $first: "$game" },
39
+ channels: { $first: "$channels" },
40
+ count: { $sum: 1 },
41
+ }
42
+ },
43
+ {
44
+ $project: {
45
+ _id: 0,
46
+ id: "$_id",
47
+ userId: 1,
48
+ userName: 1,
49
+ event: 1,
50
+ game: 1,
51
+ channel: 1,
52
+ count: 1,
53
+ date: "$_id"
54
+ }
55
+ },
56
+ {
57
+ $sort: { "date": -1 }
58
+ }
59
+ ])
60
+ }
61
+
62
+ async userIsNewbie(userId: string): Promise<boolean> {
63
+ return await this.activityLogModel.countDocuments({ userId, event: ActivityLogEnum.USER_LOGIN }).exec() === 1;
64
+ }
65
+
66
+ async getUserPlayedGamesCount(userId: string): Promise<number> {
67
+ return await this.activityLogModel.countDocuments({ userId, event: ActivityLogEnum.USER_PLAYED_GAME }).exec()
68
+ }
69
+
70
+ async getUserWonGamesCount(userId: string): Promise<number> {
71
+ return await this.activityLogModel.countDocuments({ userId, event: ActivityLogEnum.USER_WON_GAME }).exec()
72
+ }
73
+
74
+ async getUserWonProfiCount(userId: string): Promise<number> {
75
+ return await this.activityLogModel.countDocuments({ userId, event: ActivityLogEnum.USER_WON_PROFI }).exec()
76
+ }
77
+
78
+ async getUserWonOneTableTournamentCount(userId: string): Promise<number> {
79
+ return await this.activityLogModel.countDocuments({ userId, event: ActivityLogEnum.USER_WON_ONE_TABLE_TOURNAMENT }).exec()
80
+ }
81
+
82
+ async addUserLoginEvent(userId: string, userName: string, game: string, channels: string): Promise<ActivityLog> {
83
+ return this.addActivityLog({ date: new Date(), event: ActivityLogEnum.USER_LOGIN, userId, userName, game, channels });
84
+ }
85
+
86
+ async addUserGotBonuseEvent(userId: string, userName: string, game: string, channels: string, amount: number): Promise<ActivityLog> {
87
+ return this.addActivityLog({ date: new Date(), event: ActivityLogEnum.USER_GOT_BONUS, userId, userName, game, channels, amount, });
88
+ }
89
+
90
+ async addUserPlayedGameEvent(userId: string, userName: string, game: string, channels: string): Promise<ActivityLog> {
91
+ return this.addActivityLog({ date: new Date(), event: ActivityLogEnum.USER_PLAYED_GAME, userId, userName, game, channels, });
92
+ }
93
+
94
+ async addUserWonGameEvent(userId: string, userName: string, game: string, channels: string): Promise<ActivityLog> {
95
+ return this.addActivityLog({ date: new Date(), event: ActivityLogEnum.USER_WON_GAME, userId, userName, game, channels });
96
+ }
97
+
98
+ async addUserWonProfieEvent(userId: string, userName: string, game: string, channels: string): Promise<ActivityLog> {
99
+ return this.addActivityLog({ date: new Date(), event: ActivityLogEnum.USER_WON_PROFI, userId, userName, game, channels });
100
+ }
101
+
102
+ async addUserWonOneTableTournamentEvent(userId: string, userName: string, game: string, channels: string): Promise<ActivityLog> {
103
+ return this.addActivityLog({ date: new Date(), event: ActivityLogEnum.USER_WON_ONE_TABLE_TOURNAMENT, userId, userName, game, channels });
104
+ }
105
+
106
+ async addActivityLog(activityLog: Partial<ActivityLog>): Promise<ActivityLog> {
107
+ return this.activityLogModel.create(activityLog);
108
+ }
109
+ }
110
+
@@ -1,23 +1,23 @@
1
- import { Injectable } from '@nestjs/common';
2
- import { InjectModel } from '@nestjs/mongoose';
3
- import { Model } from 'mongoose';
4
-
5
- import { Admin, AdminDocument } from '../';
6
-
7
- @Injectable()
8
- export class AdminRepository {
9
- constructor (@InjectModel(Admin.name) private adminModel: Model<AdminDocument>) {
10
- }
11
-
12
- async findById (id: string): Promise<Admin | null> {
13
- return this.adminModel
14
- .findOne({ _id: id })
15
- .exec();
16
- }
17
-
18
- async findByLogin (login: string): Promise<Admin | null> {
19
- return this.adminModel
20
- .findOne({ login })
21
- .exec();
22
- }
23
- }
1
+ import { Injectable } from '@nestjs/common';
2
+ import { InjectModel } from '@nestjs/mongoose';
3
+ import { Model } from 'mongoose';
4
+
5
+ import { Admin, AdminDocument } from '../';
6
+
7
+ @Injectable()
8
+ export class AdminRepository {
9
+ constructor (@InjectModel(Admin.name) private adminModel: Model<AdminDocument>) {
10
+ }
11
+
12
+ async findById (id: string): Promise<Admin | null> {
13
+ return this.adminModel
14
+ .findOne({ _id: id })
15
+ .exec();
16
+ }
17
+
18
+ async findByLogin (login: string): Promise<Admin | null> {
19
+ return this.adminModel
20
+ .findOne({ login })
21
+ .exec();
22
+ }
23
+ }
@@ -1,33 +1,33 @@
1
- import { Injectable } from '@nestjs/common';
2
- import { InjectModel } from '@nestjs/mongoose';
3
- import { Model } from 'mongoose';
4
-
5
- import { Article, ArticleDocument } from '../';
6
-
7
- @Injectable()
8
- export class ArticleRepository {
9
- constructor (@InjectModel(Article.name) private articleModel: Model<ArticleDocument>) {
10
- }
11
-
12
- async findAllArticles (): Promise<Array<Article>> {
13
- return this.articleModel
14
- .find()
15
- .sort({ createDate: -1 })
16
- .exec();
17
- }
18
-
19
- async findLastArticle (): Promise<Article | null> {
20
- return await this.articleModel
21
- .findOne()
22
- .sort({ createDate: -1 })
23
- .exec();
24
- }
25
-
26
- async findTop3Articles (): Promise<Array<Article>> {
27
- return this.articleModel
28
- .find()
29
- .sort({ createDate: -1 })
30
- .limit(3)
31
- .exec();
32
- }
33
- }
1
+ import { Injectable } from '@nestjs/common';
2
+ import { InjectModel } from '@nestjs/mongoose';
3
+ import { Model } from 'mongoose';
4
+
5
+ import { Article, ArticleDocument } from '../';
6
+
7
+ @Injectable()
8
+ export class ArticleRepository {
9
+ constructor (@InjectModel(Article.name) private articleModel: Model<ArticleDocument>) {
10
+ }
11
+
12
+ async findAllArticles (): Promise<Array<Article>> {
13
+ return this.articleModel
14
+ .find()
15
+ .sort({ createDate: -1 })
16
+ .exec();
17
+ }
18
+
19
+ async findLastArticle (): Promise<Article | null> {
20
+ return await this.articleModel
21
+ .findOne()
22
+ .sort({ createDate: -1 })
23
+ .exec();
24
+ }
25
+
26
+ async findTop3Articles (): Promise<Array<Article>> {
27
+ return this.articleModel
28
+ .find()
29
+ .sort({ createDate: -1 })
30
+ .limit(3)
31
+ .exec();
32
+ }
33
+ }
@@ -1,15 +1,15 @@
1
- import { Injectable } from '@nestjs/common';
2
- import { InjectModel } from '@nestjs/mongoose';
3
- import { Model } from 'mongoose';
4
-
5
- import { BalanceHistory, BalanceHistoryDocument } from '../';
6
-
7
- @Injectable()
8
- export class BalanceHistoryRepository {
9
- constructor (@InjectModel(BalanceHistory.name) private balanceHistoryModel: Model<BalanceHistoryDocument>) {
10
- }
11
-
12
- public async createBalanceHistory (gameResult: Partial<BalanceHistory>): Promise<BalanceHistory> {
13
- return this.balanceHistoryModel.create(gameResult);
14
- }
15
- }
1
+ import { Injectable } from '@nestjs/common';
2
+ import { InjectModel } from '@nestjs/mongoose';
3
+ import { Model } from 'mongoose';
4
+
5
+ import { BalanceHistory, BalanceHistoryDocument } from '../';
6
+
7
+ @Injectable()
8
+ export class BalanceHistoryRepository {
9
+ constructor (@InjectModel(BalanceHistory.name) private balanceHistoryModel: Model<BalanceHistoryDocument>) {
10
+ }
11
+
12
+ public async createBalanceHistory (gameResult: Partial<BalanceHistory>): Promise<BalanceHistory> {
13
+ return this.balanceHistoryModel.create(gameResult);
14
+ }
15
+ }
@@ -1,54 +1,54 @@
1
- import { Injectable } from '@nestjs/common';
2
- import { InjectModel } from '@nestjs/mongoose';
3
- import { Model } from 'mongoose';
4
-
5
- import { Banner, BannerDocument } from '../';
6
-
7
- @Injectable()
8
- export class BannersRepository {
9
- constructor (@InjectModel(Banner.name) private bannerModel: Model<BannerDocument>) {
10
- }
11
-
12
- async findById (id: string): Promise<Banner | null> {
13
- return this.bannerModel
14
- .findById(id)
15
- .exec();
16
- }
17
-
18
- async findAndCount (limit: number, skip: number): Promise<{
19
- items: Array<Banner>,
20
- total: number
21
- }> {
22
- const items = await this.bannerModel
23
- .find()
24
- .sort({ createDate: -1 })
25
- .limit(limit)
26
- .skip(skip)
27
- .exec();
28
-
29
- const total = await this.bannerModel
30
- .find()
31
- .countDocuments()
32
- .exec();
33
-
34
- return { items, total };
35
- }
36
-
37
- public async createBanner (banner: Banner): Promise<Banner> {
38
- return this.bannerModel.create(banner);
39
- }
40
-
41
- async updateBanner (bannerId: string, banner: Partial<Banner>): Promise<void> {
42
- await this.bannerModel.findByIdAndUpdate(
43
- bannerId,
44
- {
45
- $set: {
46
- ...banner,
47
- },
48
- }).exec();
49
- }
50
-
51
- public async removeBanner (bannerId: string): Promise<void> {
52
- await this.bannerModel.findByIdAndDelete(bannerId);
53
- }
54
- }
1
+ import { Injectable } from '@nestjs/common';
2
+ import { InjectModel } from '@nestjs/mongoose';
3
+ import { Model } from 'mongoose';
4
+
5
+ import { Banner, BannerDocument } from '../';
6
+
7
+ @Injectable()
8
+ export class BannersRepository {
9
+ constructor (@InjectModel(Banner.name) private bannerModel: Model<BannerDocument>) {
10
+ }
11
+
12
+ async findById (id: string): Promise<Banner | null> {
13
+ return this.bannerModel
14
+ .findById(id)
15
+ .exec();
16
+ }
17
+
18
+ async findAndCount (limit: number, skip: number): Promise<{
19
+ items: Array<Banner>,
20
+ total: number
21
+ }> {
22
+ const items = await this.bannerModel
23
+ .find()
24
+ .sort({ createDate: -1 })
25
+ .limit(limit)
26
+ .skip(skip)
27
+ .exec();
28
+
29
+ const total = await this.bannerModel
30
+ .find()
31
+ .countDocuments()
32
+ .exec();
33
+
34
+ return { items, total };
35
+ }
36
+
37
+ public async createBanner (banner: Banner): Promise<Banner> {
38
+ return this.bannerModel.create(banner);
39
+ }
40
+
41
+ async updateBanner (bannerId: string, banner: Partial<Banner>): Promise<void> {
42
+ await this.bannerModel.findByIdAndUpdate(
43
+ bannerId,
44
+ {
45
+ $set: {
46
+ ...banner,
47
+ },
48
+ }).exec();
49
+ }
50
+
51
+ public async removeBanner (bannerId: string): Promise<void> {
52
+ await this.bannerModel.findByIdAndDelete(bannerId);
53
+ }
54
+ }
@@ -1,30 +1,30 @@
1
- import { Injectable } from '@nestjs/common';
2
- import { InjectModel } from '@nestjs/mongoose';
3
- import { Model } from 'mongoose';
4
-
5
- import { Complain, ComplainDocument } from '../';
6
-
7
- @Injectable()
8
- export class ComplainsRepository {
9
- constructor (@InjectModel(Complain.name) private complainModel: Model<ComplainDocument>) {
10
- }
11
-
12
- async findAndCount (limit: number, skip: number): Promise<{
13
- items: Array<Complain>,
14
- total: number
15
- }> {
16
- const items = await this.complainModel
17
- .find()
18
- .sort({ createDate: -1 })
19
- .limit(limit)
20
- .skip(skip)
21
- .exec();
22
-
23
- const total = await this.complainModel
24
- .find()
25
- .countDocuments()
26
- .exec();
27
-
28
- return { items, total };
29
- }
30
- }
1
+ import { Injectable } from '@nestjs/common';
2
+ import { InjectModel } from '@nestjs/mongoose';
3
+ import { Model } from 'mongoose';
4
+
5
+ import { Complain, ComplainDocument } from '../';
6
+
7
+ @Injectable()
8
+ export class ComplainsRepository {
9
+ constructor (@InjectModel(Complain.name) private complainModel: Model<ComplainDocument>) {
10
+ }
11
+
12
+ async findAndCount (limit: number, skip: number): Promise<{
13
+ items: Array<Complain>,
14
+ total: number
15
+ }> {
16
+ const items = await this.complainModel
17
+ .find()
18
+ .sort({ createDate: -1 })
19
+ .limit(limit)
20
+ .skip(skip)
21
+ .exec();
22
+
23
+ const total = await this.complainModel
24
+ .find()
25
+ .countDocuments()
26
+ .exec();
27
+
28
+ return { items, total };
29
+ }
30
+ }
@@ -1,26 +1,26 @@
1
- import { Injectable } from '@nestjs/common';
2
- import { InjectModel } from '@nestjs/mongoose';
3
- import { Model } from 'mongoose';
4
-
5
- import { DailyBonus, DailyBonusDocument } from '../';
6
- import { getChannelRegExpFilter } from '../utils';
7
-
8
- @Injectable()
9
- export class DailyBonusRepository {
10
- constructor(@InjectModel(DailyBonus.name) private dailyBonusModel: Model<DailyBonusDocument>) {
11
- }
12
-
13
- async findDailyBonuses(channel: string, game: string): Promise<Array<DailyBonus> | null> {
14
- return this.dailyBonusModel
15
- .find({
16
- channels: getChannelRegExpFilter(channel),
17
- })
18
- .exec();
19
- }
20
-
21
- async findDailyBonusByDay(day: number, game: string): Promise<DailyBonus | null> {
22
- return this.dailyBonusModel
23
- .findOne({ game, position: day })
24
- .exec();
25
- }
1
+ import { Injectable } from '@nestjs/common';
2
+ import { InjectModel } from '@nestjs/mongoose';
3
+ import { Model } from 'mongoose';
4
+
5
+ import { DailyBonus, DailyBonusDocument } from '../';
6
+ import { getChannelRegExpFilter } from '../utils';
7
+
8
+ @Injectable()
9
+ export class DailyBonusRepository {
10
+ constructor(@InjectModel(DailyBonus.name) private dailyBonusModel: Model<DailyBonusDocument>) {
11
+ }
12
+
13
+ async findDailyBonuses(channel: string, game: string): Promise<Array<DailyBonus> | null> {
14
+ return this.dailyBonusModel
15
+ .find({
16
+ channels: getChannelRegExpFilter(channel),
17
+ })
18
+ .exec();
19
+ }
20
+
21
+ async findDailyBonusByDay(day: number, game: string): Promise<DailyBonus | null> {
22
+ return this.dailyBonusModel
23
+ .findOne({ game, position: day })
24
+ .exec();
25
+ }
26
26
  }