jp.db.schemas 2.0.26 → 2.1.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 (90) hide show
  1. package/dist/index.d.ts +6 -4
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +5 -1
  4. package/dist/index.js.map +1 -1
  5. package/dist/models/activity-log.enum.d.ts +5 -0
  6. package/dist/models/activity-log.enum.d.ts.map +1 -0
  7. package/dist/models/activity-log.enum.js +9 -0
  8. package/dist/models/activity-log.enum.js.map +1 -0
  9. package/dist/repositories/activity-log.repository.d.ts +11 -0
  10. package/dist/repositories/activity-log.repository.d.ts.map +1 -0
  11. package/dist/repositories/activity-log.repository.js +93 -0
  12. package/dist/repositories/activity-log.repository.js.map +1 -0
  13. package/dist/repositories/index.d.ts +2 -1
  14. package/dist/repositories/index.d.ts.map +1 -1
  15. package/dist/repositories/index.js +3 -1
  16. package/dist/repositories/index.js.map +1 -1
  17. package/dist/schemas/activity_log.schema.d.ts +105 -0
  18. package/dist/schemas/activity_log.schema.d.ts.map +1 -0
  19. package/dist/schemas/activity_log.schema.js +57 -0
  20. package/dist/schemas/activity_log.schema.js.map +1 -0
  21. package/dist/schemas/daily_bonus.schema.d.ts +12 -0
  22. package/dist/schemas/daily_bonus.schema.d.ts.map +1 -1
  23. package/dist/schemas/daily_bonus.schema.js +8 -0
  24. package/dist/schemas/daily_bonus.schema.js.map +1 -1
  25. package/package.json +31 -30
  26. package/readme.md +3 -3
  27. package/src/index.ts +226 -219
  28. package/src/models/activity-log.enum.ts +4 -0
  29. package/src/models/tournament-participant.interface.ts +5 -5
  30. package/src/models/tournament-status.enum.ts +6 -6
  31. package/src/models/tournament-template.enum.ts +3 -3
  32. package/src/models/tournament-winner.interface.ts +7 -7
  33. package/src/repositories/activity-log.repository.ts +93 -0
  34. package/src/repositories/admin.repository.ts +23 -23
  35. package/src/repositories/article.repository.ts +33 -33
  36. package/src/repositories/balance-history.repository.ts +15 -15
  37. package/src/repositories/banners.repository.ts +54 -54
  38. package/src/repositories/complains.repository.ts +30 -30
  39. package/src/repositories/daily-bonus.repository.ts +19 -19
  40. package/src/repositories/game-result.repository.ts +15 -15
  41. package/src/repositories/index.ts +47 -45
  42. package/src/repositories/menu.repository.ts +21 -21
  43. package/src/repositories/notification.repository.ts +54 -54
  44. package/src/repositories/premium.repository.ts +19 -19
  45. package/src/repositories/products.repository.ts +29 -29
  46. package/src/repositories/rooms.repository.ts +17 -17
  47. package/src/repositories/rule.repository.ts +19 -19
  48. package/src/repositories/scheduled-tournaments.repository.ts +30 -30
  49. package/src/repositories/servers.repository.ts +18 -18
  50. package/src/repositories/setting.repository.ts +19 -19
  51. package/src/repositories/simple-rooms.repository.ts +17 -17
  52. package/src/repositories/tournament-many-tables-rooms.repository.ts +132 -132
  53. package/src/repositories/tournament-one-table-rooms.repository.ts +106 -106
  54. package/src/repositories/users.repository.ts +124 -124
  55. package/src/repositories/welcome.repository.ts +19 -19
  56. package/src/schemas/achievement.schema.ts +40 -40
  57. package/src/schemas/activity_log.schema.ts +37 -0
  58. package/src/schemas/admin.schema.ts +22 -22
  59. package/src/schemas/article.schema.ts +37 -37
  60. package/src/schemas/balance_history.schema.ts +37 -37
  61. package/src/schemas/banner.schema.ts +40 -40
  62. package/src/schemas/channel_message.schema.ts +31 -31
  63. package/src/schemas/complain.schema.ts +46 -46
  64. package/src/schemas/daily_bonus.schema.ts +56 -50
  65. package/src/schemas/feature.schema.ts +28 -28
  66. package/src/schemas/game_result.schema.ts +68 -68
  67. package/src/schemas/menu.schema.ts +40 -40
  68. package/src/schemas/notification.schema.ts +61 -61
  69. package/src/schemas/premium.schema.ts +45 -45
  70. package/src/schemas/product.schema.ts +123 -123
  71. package/src/schemas/purchase.schema.ts +64 -64
  72. package/src/schemas/purchase_channel.schema.ts +31 -31
  73. package/src/schemas/rating.schema.ts +46 -46
  74. package/src/schemas/rooms.schema.ts +63 -63
  75. package/src/schemas/rule.schema.ts +45 -45
  76. package/src/schemas/scheduled_tournament.schema.ts +93 -93
  77. package/src/schemas/server.schema.ts +22 -22
  78. package/src/schemas/setting.schema.ts +55 -55
  79. package/src/schemas/simple_rooms.schema.ts +46 -46
  80. package/src/schemas/tournament_many_tables_rooms.schema.ts +84 -84
  81. package/src/schemas/tournament_one_table_rooms.schema.ts +81 -81
  82. package/src/schemas/user.fb.schema.ts +33 -33
  83. package/src/schemas/user.google.schema.ts +24 -24
  84. package/src/schemas/user.ok.schema.ts +52 -52
  85. package/src/schemas/user.schema.ts +184 -184
  86. package/src/schemas/user.tg.schema.ts +30 -30
  87. package/src/schemas/user.vk.schema.ts +70 -70
  88. package/src/schemas/user.ya.schema.ts +24 -24
  89. package/src/schemas/welcome.schema.ts +45 -45
  90. package/src/utils.ts +3 -3
@@ -1,29 +1,29 @@
1
- import { Injectable } from '@nestjs/common';
2
- import { InjectModel } from '@nestjs/mongoose';
3
- import { Model } from 'mongoose';
4
-
5
- import { Product, ProductDocument } from '../';
6
- import { getChannelRegExpFilter } from '../utils';
7
-
8
- @Injectable()
9
- export class ProductsRepository {
10
- constructor (@InjectModel(Product.name) private productModel: Model<ProductDocument>) {
11
- }
12
-
13
- async findByProductId (productId: string): Promise<Product | null> {
14
- return this.productModel
15
- .findOne({ productId })
16
- .exec();
17
- }
18
-
19
- async findProducts (parentId: string | null, channel: string): Promise<Array<Product> | null> {
20
- return this.productModel
21
- .find({
22
- parentId,
23
- active: true,
24
- channels: getChannelRegExpFilter(channel),
25
- })
26
- .exec();
27
- }
28
- }
29
-
1
+ import { Injectable } from '@nestjs/common';
2
+ import { InjectModel } from '@nestjs/mongoose';
3
+ import { Model } from 'mongoose';
4
+
5
+ import { Product, ProductDocument } from '../';
6
+ import { getChannelRegExpFilter } from '../utils';
7
+
8
+ @Injectable()
9
+ export class ProductsRepository {
10
+ constructor (@InjectModel(Product.name) private productModel: Model<ProductDocument>) {
11
+ }
12
+
13
+ async findByProductId (productId: string): Promise<Product | null> {
14
+ return this.productModel
15
+ .findOne({ productId })
16
+ .exec();
17
+ }
18
+
19
+ async findProducts (parentId: string | null, channel: string): Promise<Array<Product> | null> {
20
+ return this.productModel
21
+ .find({
22
+ parentId,
23
+ active: true,
24
+ channels: getChannelRegExpFilter(channel),
25
+ })
26
+ .exec();
27
+ }
28
+ }
29
+
@@ -1,17 +1,17 @@
1
- import { Injectable } from '@nestjs/common';
2
- import { InjectModel } from '@nestjs/mongoose';
3
- import { Model } from 'mongoose';
4
-
5
- import { Room, RoomDocument } from '../';
6
-
7
- @Injectable()
8
- export class RoomsRepository {
9
- constructor (@InjectModel(Room.name) private roomModel: Model<RoomDocument>) {
10
- }
11
-
12
- async findRooms (gameType: string): Promise<Array<RoomDocument>> {
13
- return this.roomModel
14
- .find({ gameType })
15
- .exec();
16
- }
17
- }
1
+ import { Injectable } from '@nestjs/common';
2
+ import { InjectModel } from '@nestjs/mongoose';
3
+ import { Model } from 'mongoose';
4
+
5
+ import { Room, RoomDocument } from '../';
6
+
7
+ @Injectable()
8
+ export class RoomsRepository {
9
+ constructor (@InjectModel(Room.name) private roomModel: Model<RoomDocument>) {
10
+ }
11
+
12
+ async findRooms (gameType: string): Promise<Array<RoomDocument>> {
13
+ return this.roomModel
14
+ .find({ gameType })
15
+ .exec();
16
+ }
17
+ }
@@ -1,20 +1,20 @@
1
- import { Injectable } from '@nestjs/common';
2
- import { InjectModel } from '@nestjs/mongoose';
3
- import { Model } from 'mongoose';
4
-
5
- import { Rule, RuleDocument } from '..';
6
- import { getChannelRegExpFilter } from '../utils';
7
-
8
- @Injectable()
9
- export class RuleRepository {
10
- constructor (@InjectModel(Rule.name) private ruleModel: Model<RuleDocument>) {
11
- }
12
-
13
- async findRule (channel: string, game: string): Promise<Array<Rule> | null> {
14
- return this.ruleModel
15
- .find({
16
- channels: getChannelRegExpFilter(channel),
17
- })
18
- .exec();
19
- }
1
+ import { Injectable } from '@nestjs/common';
2
+ import { InjectModel } from '@nestjs/mongoose';
3
+ import { Model } from 'mongoose';
4
+
5
+ import { Rule, RuleDocument } from '..';
6
+ import { getChannelRegExpFilter } from '../utils';
7
+
8
+ @Injectable()
9
+ export class RuleRepository {
10
+ constructor (@InjectModel(Rule.name) private ruleModel: Model<RuleDocument>) {
11
+ }
12
+
13
+ async findRule (channel: string, game: string): Promise<Array<Rule> | null> {
14
+ return this.ruleModel
15
+ .find({
16
+ channels: getChannelRegExpFilter(channel),
17
+ })
18
+ .exec();
19
+ }
20
20
  }
@@ -1,30 +1,30 @@
1
- import { Injectable } from '@nestjs/common';
2
- import { InjectModel } from '@nestjs/mongoose';
3
- import { Model } from 'mongoose';
4
-
5
- import { ScheduledTournament, ScheduledTournamentDocument } from '../';
6
-
7
- @Injectable()
8
- export class ScheduledTournamentsRepository {
9
- constructor (@InjectModel(ScheduledTournament.name) private scheduledTournamentModel: Model<ScheduledTournamentDocument>) {
10
- }
11
-
12
- async findAndCount (limit: number, skip: number): Promise<{
13
- items: Array<ScheduledTournament>,
14
- total: number
15
- }> {
16
- const items = await this.scheduledTournamentModel
17
- .find({ category: 'global'})
18
- .sort({ date: -1 })
19
- .limit(limit)
20
- .skip(skip)
21
- .exec();
22
-
23
- const total = await this.scheduledTournamentModel
24
- .find({ category: 'global'})
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 { ScheduledTournament, ScheduledTournamentDocument } from '../';
6
+
7
+ @Injectable()
8
+ export class ScheduledTournamentsRepository {
9
+ constructor (@InjectModel(ScheduledTournament.name) private scheduledTournamentModel: Model<ScheduledTournamentDocument>) {
10
+ }
11
+
12
+ async findAndCount (limit: number, skip: number): Promise<{
13
+ items: Array<ScheduledTournament>,
14
+ total: number
15
+ }> {
16
+ const items = await this.scheduledTournamentModel
17
+ .find({ category: 'global'})
18
+ .sort({ date: -1 })
19
+ .limit(limit)
20
+ .skip(skip)
21
+ .exec();
22
+
23
+ const total = await this.scheduledTournamentModel
24
+ .find({ category: 'global'})
25
+ .countDocuments()
26
+ .exec();
27
+
28
+ return { items, total };
29
+ }
30
+ }
@@ -1,18 +1,18 @@
1
- import { Injectable } from '@nestjs/common';
2
- import { InjectModel } from '@nestjs/mongoose';
3
- import { Model } from 'mongoose';
4
-
5
- import { Server, ServerDocument } from '../';
6
-
7
- @Injectable()
8
- export class ServersRepository {
9
- constructor (@InjectModel(Server.name) private serverModel: Model<ServerDocument>) {
10
- }
11
-
12
- async findServerByName (name: string): Promise<Server | null> {
13
- return this.serverModel
14
- .findOne({name})
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 { Server, ServerDocument } from '../';
6
+
7
+ @Injectable()
8
+ export class ServersRepository {
9
+ constructor (@InjectModel(Server.name) private serverModel: Model<ServerDocument>) {
10
+ }
11
+
12
+ async findServerByName (name: string): Promise<Server | null> {
13
+ return this.serverModel
14
+ .findOne({name})
15
+ .exec();
16
+ }
17
+ }
18
+
@@ -1,20 +1,20 @@
1
- import { Injectable } from '@nestjs/common';
2
- import { InjectModel } from '@nestjs/mongoose';
3
- import { Model } from 'mongoose';
4
-
5
- import { Setting, SettingDocument } from '..';
6
- import { getChannelRegExpFilter } from '../utils';
7
-
8
- @Injectable()
9
- export class SettingRepository {
10
- constructor (@InjectModel(Setting.name) private settingModel: Model<SettingDocument>) {
11
- }
12
-
13
- async findSetting (channel: string, game: string): Promise<Array<Setting> | null> {
14
- return this.settingModel
15
- .find({
16
- channels: getChannelRegExpFilter(channel),
17
- })
18
- .exec();
19
- }
1
+ import { Injectable } from '@nestjs/common';
2
+ import { InjectModel } from '@nestjs/mongoose';
3
+ import { Model } from 'mongoose';
4
+
5
+ import { Setting, SettingDocument } from '..';
6
+ import { getChannelRegExpFilter } from '../utils';
7
+
8
+ @Injectable()
9
+ export class SettingRepository {
10
+ constructor (@InjectModel(Setting.name) private settingModel: Model<SettingDocument>) {
11
+ }
12
+
13
+ async findSetting (channel: string, game: string): Promise<Array<Setting> | null> {
14
+ return this.settingModel
15
+ .find({
16
+ channels: getChannelRegExpFilter(channel),
17
+ })
18
+ .exec();
19
+ }
20
20
  }
@@ -1,17 +1,17 @@
1
- import { Injectable } from '@nestjs/common';
2
- import { InjectModel } from '@nestjs/mongoose';
3
- import { Model } from 'mongoose';
4
-
5
- import { SimpleRoom, SimpleRoomDocument } from '../';
6
-
7
- @Injectable()
8
- export class SimpleRoomsRepository {
9
- constructor (@InjectModel(SimpleRoom.name) private roomModel: Model<SimpleRoomDocument>) {
10
- }
11
-
12
- async findRooms (gameType: string): Promise<Array<SimpleRoomDocument>> {
13
- return this.roomModel
14
- .find({ gameType })
15
- .exec();
16
- }
17
- }
1
+ import { Injectable } from '@nestjs/common';
2
+ import { InjectModel } from '@nestjs/mongoose';
3
+ import { Model } from 'mongoose';
4
+
5
+ import { SimpleRoom, SimpleRoomDocument } from '../';
6
+
7
+ @Injectable()
8
+ export class SimpleRoomsRepository {
9
+ constructor (@InjectModel(SimpleRoom.name) private roomModel: Model<SimpleRoomDocument>) {
10
+ }
11
+
12
+ async findRooms (gameType: string): Promise<Array<SimpleRoomDocument>> {
13
+ return this.roomModel
14
+ .find({ gameType })
15
+ .exec();
16
+ }
17
+ }
@@ -1,132 +1,132 @@
1
- import { Injectable } from '@nestjs/common';
2
- import { InjectModel } from '@nestjs/mongoose';
3
- import { Model } from 'mongoose';
4
-
5
- import {
6
- TournamentManyTablesRoom,
7
- TournamentManyTablesRoomDocument,
8
- TournamentOneTableRoomDocument,
9
- } from '../';
10
- import { TournamentStatusEnum } from '../models/tournament-status.enum';
11
- import { ITournamentWinner } from '../models/tournament-winner.interface';
12
- import { TournamentTemplateEnum } from '../models/tournament-template.enum';
13
- import { ITournamentParticipant } from '../models/tournament-participant.interface';
14
-
15
- @Injectable()
16
- export class TournamentManyTablesRoomsRepository {
17
- constructor (@InjectModel(TournamentManyTablesRoom.name) private tournamentModel: Model<TournamentManyTablesRoomDocument>) {
18
- }
19
-
20
- async findTournamentById (tournamentId: string): Promise<TournamentManyTablesRoomDocument | null> {
21
- return this.tournamentModel
22
- .findById(tournamentId)
23
- .exec();
24
- }
25
-
26
- async findTemplateById (templateId: string, gameType: string): Promise<TournamentOneTableRoomDocument | null> {
27
- return this.tournamentModel
28
- .findOne({ templateId, gameType })
29
- .exec();
30
- }
31
-
32
- async findTournaments (gameType: string): Promise<Array<TournamentManyTablesRoomDocument>> {
33
- return this.tournamentModel
34
- .find({ gameType, isTemplate: false })
35
- .exec();
36
- }
37
-
38
- async findWaitingTournamentByDate (gameType: string, startDate: Date, endDate: Date): Promise<TournamentOneTableRoomDocument | null> {
39
- return this.tournamentModel
40
- .findOne({
41
- gameType,
42
- status: TournamentStatusEnum.STATE_WAITING_FOR_START,
43
- isTemplate: false,
44
- scheduleDate: { $gte: startDate, $lt: endDate },
45
- })
46
- .exec();
47
- }
48
-
49
- async createTournament (tournament: Partial<TournamentManyTablesRoom>): Promise<TournamentManyTablesRoomDocument> {
50
- return this.tournamentModel.create(tournament)
51
- }
52
-
53
- async scheduleTournamentFromMasterTemplate (gameType: string, scheduleDate: Date): Promise<TournamentManyTablesRoomDocument> {
54
- const masterTemplate = await this.findTemplateById(TournamentTemplateEnum.MASTER, gameType);
55
-
56
- return this.createTournament({
57
- title: masterTemplate.title,
58
- subtitle: masterTemplate.subtitle,
59
- description: masterTemplate.description,
60
- tableSize: masterTemplate.tableSize,
61
- bet: masterTemplate.bet,
62
- ticketPrice: masterTemplate.ticketPrice,
63
- roomType: masterTemplate.roomType,
64
- gameType: masterTemplate.gameType,
65
- rulesType: masterTemplate.rulesType,
66
- deckType: masterTemplate.deckType,
67
- maxParticipants: masterTemplate.maxParticipants,
68
- participants: masterTemplate.participants,
69
- status: masterTemplate.status,
70
- winners: masterTemplate.winners,
71
- createDate: new Date(),
72
- isTemplate: false,
73
- templateId: undefined,
74
- scheduleDate,
75
- });
76
- }
77
-
78
- async updateTournament (tournamentId: string, tournament: Partial<TournamentManyTablesRoom>): Promise<TournamentManyTablesRoomDocument> {
79
- return this.tournamentModel.findByIdAndUpdate(
80
- tournamentId,
81
- {
82
- $set: {
83
- ...tournament,
84
- },
85
- }).exec();
86
- }
87
-
88
- async removeTournament (tournamentId: string): Promise<void> {
89
- await this.tournamentModel.findByIdAndDelete(tournamentId);
90
- }
91
-
92
- async startTournament (tournamentId: string): Promise<void> {
93
- await this.tournamentModel.findByIdAndUpdate(
94
- tournamentId,
95
- {
96
- $set: {
97
- startDate: new Date(),
98
- status: TournamentStatusEnum.STATE_IN_PROGRESS,
99
- },
100
- }).exec();
101
- }
102
-
103
- async cancelTournament (tournamentId: string): Promise<void> {
104
- await this.tournamentModel.findByIdAndUpdate(
105
- tournamentId,
106
- {
107
- $set: {
108
- finishDate: new Date(),
109
- status: TournamentStatusEnum.STATE_CANCELLED,
110
- },
111
- }).exec();
112
- }
113
-
114
- async finishTournament (tournamentId: string, winners: Array<ITournamentWinner>): Promise<void> {
115
- await this.tournamentModel.findByIdAndUpdate(
116
- tournamentId,
117
- {
118
- $set: {
119
- finishDate: new Date(),
120
- status: TournamentStatusEnum.STATE_FINISHED,
121
- winners,
122
- },
123
- }).exec();
124
- }
125
-
126
- async addPlayerToParticipants (tournamentId: string, player: ITournamentParticipant): Promise<void> {
127
- await this.tournamentModel.findByIdAndUpdate(
128
- tournamentId,
129
- { $push: { participants: player } })
130
- .exec();
131
- }
132
- }
1
+ import { Injectable } from '@nestjs/common';
2
+ import { InjectModel } from '@nestjs/mongoose';
3
+ import { Model } from 'mongoose';
4
+
5
+ import {
6
+ TournamentManyTablesRoom,
7
+ TournamentManyTablesRoomDocument,
8
+ TournamentOneTableRoomDocument,
9
+ } from '../';
10
+ import { TournamentStatusEnum } from '../models/tournament-status.enum';
11
+ import { ITournamentWinner } from '../models/tournament-winner.interface';
12
+ import { TournamentTemplateEnum } from '../models/tournament-template.enum';
13
+ import { ITournamentParticipant } from '../models/tournament-participant.interface';
14
+
15
+ @Injectable()
16
+ export class TournamentManyTablesRoomsRepository {
17
+ constructor (@InjectModel(TournamentManyTablesRoom.name) private tournamentModel: Model<TournamentManyTablesRoomDocument>) {
18
+ }
19
+
20
+ async findTournamentById (tournamentId: string): Promise<TournamentManyTablesRoomDocument | null> {
21
+ return this.tournamentModel
22
+ .findById(tournamentId)
23
+ .exec();
24
+ }
25
+
26
+ async findTemplateById (templateId: string, gameType: string): Promise<TournamentOneTableRoomDocument | null> {
27
+ return this.tournamentModel
28
+ .findOne({ templateId, gameType })
29
+ .exec();
30
+ }
31
+
32
+ async findTournaments (gameType: string): Promise<Array<TournamentManyTablesRoomDocument>> {
33
+ return this.tournamentModel
34
+ .find({ gameType, isTemplate: false })
35
+ .exec();
36
+ }
37
+
38
+ async findWaitingTournamentByDate (gameType: string, startDate: Date, endDate: Date): Promise<TournamentOneTableRoomDocument | null> {
39
+ return this.tournamentModel
40
+ .findOne({
41
+ gameType,
42
+ status: TournamentStatusEnum.STATE_WAITING_FOR_START,
43
+ isTemplate: false,
44
+ scheduleDate: { $gte: startDate, $lt: endDate },
45
+ })
46
+ .exec();
47
+ }
48
+
49
+ async createTournament (tournament: Partial<TournamentManyTablesRoom>): Promise<TournamentManyTablesRoomDocument> {
50
+ return this.tournamentModel.create(tournament)
51
+ }
52
+
53
+ async scheduleTournamentFromMasterTemplate (gameType: string, scheduleDate: Date): Promise<TournamentManyTablesRoomDocument> {
54
+ const masterTemplate = await this.findTemplateById(TournamentTemplateEnum.MASTER, gameType);
55
+
56
+ return this.createTournament({
57
+ title: masterTemplate.title,
58
+ subtitle: masterTemplate.subtitle,
59
+ description: masterTemplate.description,
60
+ tableSize: masterTemplate.tableSize,
61
+ bet: masterTemplate.bet,
62
+ ticketPrice: masterTemplate.ticketPrice,
63
+ roomType: masterTemplate.roomType,
64
+ gameType: masterTemplate.gameType,
65
+ rulesType: masterTemplate.rulesType,
66
+ deckType: masterTemplate.deckType,
67
+ maxParticipants: masterTemplate.maxParticipants,
68
+ participants: masterTemplate.participants,
69
+ status: masterTemplate.status,
70
+ winners: masterTemplate.winners,
71
+ createDate: new Date(),
72
+ isTemplate: false,
73
+ templateId: undefined,
74
+ scheduleDate,
75
+ });
76
+ }
77
+
78
+ async updateTournament (tournamentId: string, tournament: Partial<TournamentManyTablesRoom>): Promise<TournamentManyTablesRoomDocument> {
79
+ return this.tournamentModel.findByIdAndUpdate(
80
+ tournamentId,
81
+ {
82
+ $set: {
83
+ ...tournament,
84
+ },
85
+ }).exec();
86
+ }
87
+
88
+ async removeTournament (tournamentId: string): Promise<void> {
89
+ await this.tournamentModel.findByIdAndDelete(tournamentId);
90
+ }
91
+
92
+ async startTournament (tournamentId: string): Promise<void> {
93
+ await this.tournamentModel.findByIdAndUpdate(
94
+ tournamentId,
95
+ {
96
+ $set: {
97
+ startDate: new Date(),
98
+ status: TournamentStatusEnum.STATE_IN_PROGRESS,
99
+ },
100
+ }).exec();
101
+ }
102
+
103
+ async cancelTournament (tournamentId: string): Promise<void> {
104
+ await this.tournamentModel.findByIdAndUpdate(
105
+ tournamentId,
106
+ {
107
+ $set: {
108
+ finishDate: new Date(),
109
+ status: TournamentStatusEnum.STATE_CANCELLED,
110
+ },
111
+ }).exec();
112
+ }
113
+
114
+ async finishTournament (tournamentId: string, winners: Array<ITournamentWinner>): Promise<void> {
115
+ await this.tournamentModel.findByIdAndUpdate(
116
+ tournamentId,
117
+ {
118
+ $set: {
119
+ finishDate: new Date(),
120
+ status: TournamentStatusEnum.STATE_FINISHED,
121
+ winners,
122
+ },
123
+ }).exec();
124
+ }
125
+
126
+ async addPlayerToParticipants (tournamentId: string, player: ITournamentParticipant): Promise<void> {
127
+ await this.tournamentModel.findByIdAndUpdate(
128
+ tournamentId,
129
+ { $push: { participants: player } })
130
+ .exec();
131
+ }
132
+ }