jp.db.schemas 2.0.1 → 2.0.2

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 (51) hide show
  1. package/dist/index.d.ts +12 -4
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +17 -1
  4. package/dist/index.js.map +1 -1
  5. package/dist/repositories/index.d.ts +5 -1
  6. package/dist/repositories/index.d.ts.map +1 -1
  7. package/dist/repositories/index.js +9 -1
  8. package/dist/repositories/index.js.map +1 -1
  9. package/dist/repositories/simple-rooms.repository.d.ts +8 -0
  10. package/dist/repositories/simple-rooms.repository.d.ts.map +1 -0
  11. package/dist/repositories/simple-rooms.repository.js +36 -0
  12. package/dist/repositories/simple-rooms.repository.js.map +1 -0
  13. package/dist/repositories/tournament-many-tables-rooms.repository.d.ts +8 -0
  14. package/dist/repositories/tournament-many-tables-rooms.repository.d.ts.map +1 -0
  15. package/dist/repositories/tournament-many-tables-rooms.repository.js +36 -0
  16. package/dist/repositories/tournament-many-tables-rooms.repository.js.map +1 -0
  17. package/dist/repositories/tournament-one-table-rooms.repository.d.ts +8 -0
  18. package/dist/repositories/tournament-one-table-rooms.repository.d.ts.map +1 -0
  19. package/dist/repositories/tournament-one-table-rooms.repository.js +36 -0
  20. package/dist/repositories/tournament-one-table-rooms.repository.js.map +1 -0
  21. package/dist/repositories/tournament-result.repository.d.ts +9 -0
  22. package/dist/repositories/tournament-result.repository.d.ts.map +1 -0
  23. package/dist/repositories/tournament-result.repository.js +39 -0
  24. package/dist/repositories/tournament-result.repository.js.map +1 -0
  25. package/dist/schemas/simple_rooms.schema.d.ts +125 -0
  26. package/dist/schemas/simple_rooms.schema.d.ts.map +1 -0
  27. package/dist/schemas/simple_rooms.schema.js +65 -0
  28. package/dist/schemas/simple_rooms.schema.js.map +1 -0
  29. package/dist/schemas/tournament_many_tables_rooms.schema.d.ts +200 -0
  30. package/dist/schemas/tournament_many_tables_rooms.schema.d.ts.map +1 -0
  31. package/dist/schemas/tournament_many_tables_rooms.schema.js +93 -0
  32. package/dist/schemas/tournament_many_tables_rooms.schema.js.map +1 -0
  33. package/dist/schemas/tournament_one_table_rooms.schema.d.ts +125 -0
  34. package/dist/schemas/tournament_one_table_rooms.schema.d.ts.map +1 -0
  35. package/dist/schemas/tournament_one_table_rooms.schema.js +65 -0
  36. package/dist/schemas/tournament_one_table_rooms.schema.js.map +1 -0
  37. package/dist/schemas/tournament_result.schema.d.ts +82 -0
  38. package/dist/schemas/tournament_result.schema.d.ts.map +1 -0
  39. package/dist/schemas/tournament_result.schema.js +45 -0
  40. package/dist/schemas/tournament_result.schema.js.map +1 -0
  41. package/package.json +1 -1
  42. package/src/index.ts +28 -0
  43. package/src/repositories/index.ts +8 -0
  44. package/src/repositories/simple-rooms.repository.ts +17 -0
  45. package/src/repositories/tournament-many-tables-rooms.repository.ts +17 -0
  46. package/src/repositories/tournament-one-table-rooms.repository.ts +17 -0
  47. package/src/repositories/tournament-result.repository.ts +21 -0
  48. package/src/schemas/simple_rooms.schema.ts +43 -0
  49. package/src/schemas/tournament_many_tables_rooms.schema.ts +70 -0
  50. package/src/schemas/tournament_one_table_rooms.schema.ts +43 -0
  51. package/src/schemas/tournament_result.schema.ts +36 -0
package/src/index.ts CHANGED
@@ -50,6 +50,14 @@ import { GameResult, GameResultSchema } from './schemas/game_result.schema';
50
50
  import type { GameResultDocument } from './schemas/game_result.schema';
51
51
  import { BalanceHistory, BalanceHistorySchema } from './schemas/balance_history.schema';
52
52
  import type { BalanceHistoryDocument } from './schemas/balance_history.schema';
53
+ import { SimpleRoom, SimpleRoomSchema } from './schemas/simple_rooms.schema';
54
+ import type { SimpleRoomDocument } from './schemas/simple_rooms.schema';
55
+ import { TournamentOneTableRoom, TournamentOneTableRoomSchema, } from './schemas/tournament_one_table_rooms.schema';
56
+ import type { TournamentOneTableRoomDocument } from './schemas/tournament_one_table_rooms.schema';
57
+ import { TournamentManyTablesRoom, TournamentManyTablesRoomSchema } from './schemas/tournament_many_tables_rooms.schema';
58
+ import type { TournamentManyTablesRoomDocument } from './schemas/tournament_many_tables_rooms.schema';
59
+ import { TournamentResult, TournamentResultSchema } from './schemas/tournament_result.schema';
60
+ import type { TournamentResultDocument } from './schemas/tournament_result.schema';
53
61
 
54
62
  import {
55
63
  AdminRepository,
@@ -65,6 +73,10 @@ import {
65
73
  RoomsRepository,
66
74
  GameResultRepository,
67
75
  BalanceHistoryRepository,
76
+ SimpleRoomsRepository,
77
+ TournamentOneTableRoomsRepository,
78
+ TournamentManyTablesRoomsRepository,
79
+ TournamentResultRepository,
68
80
  } from './repositories'
69
81
 
70
82
  export type {
@@ -94,6 +106,10 @@ export type {
94
106
  MenuDocument,
95
107
  GameResultDocument,
96
108
  BalanceHistoryDocument,
109
+ SimpleRoomDocument,
110
+ TournamentOneTableRoomDocument,
111
+ TournamentManyTablesRoomDocument,
112
+ TournamentResultDocument,
97
113
  }
98
114
 
99
115
  export {
@@ -149,6 +165,14 @@ export {
149
165
  GameResultSchema,
150
166
  BalanceHistory,
151
167
  BalanceHistorySchema,
168
+ SimpleRoom,
169
+ SimpleRoomSchema,
170
+ TournamentOneTableRoom,
171
+ TournamentOneTableRoomSchema,
172
+ TournamentManyTablesRoom,
173
+ TournamentManyTablesRoomSchema,
174
+ TournamentResult,
175
+ TournamentResultSchema,
152
176
  }
153
177
 
154
178
  export {
@@ -165,4 +189,8 @@ export {
165
189
  RoomsRepository,
166
190
  GameResultRepository,
167
191
  BalanceHistoryRepository,
192
+ SimpleRoomsRepository,
193
+ TournamentOneTableRoomsRepository,
194
+ TournamentManyTablesRoomsRepository,
195
+ TournamentResultRepository,
168
196
  }
@@ -11,6 +11,10 @@ import { MenuRepository } from './menu.repository';
11
11
  import { RoomsRepository } from './rooms.repository';
12
12
  import { GameResultRepository } from './game-result.repository';
13
13
  import { BalanceHistoryRepository } from './balance-history.repository';
14
+ import { SimpleRoomsRepository } from './simple-rooms.repository';
15
+ import { TournamentOneTableRoomsRepository } from './tournament-one-table-rooms.repository';
16
+ import { TournamentManyTablesRoomsRepository } from './tournament-many-tables-rooms.repository';
17
+ import { TournamentResultRepository } from './tournament-result.repository';
14
18
 
15
19
  export {
16
20
  AdminRepository,
@@ -26,4 +30,8 @@ export {
26
30
  RoomsRepository,
27
31
  GameResultRepository,
28
32
  BalanceHistoryRepository,
33
+ SimpleRoomsRepository,
34
+ TournamentOneTableRoomsRepository,
35
+ TournamentManyTablesRoomsRepository,
36
+ TournamentResultRepository,
29
37
  }
@@ -0,0 +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
+ }
@@ -0,0 +1,17 @@
1
+ import { Injectable } from '@nestjs/common';
2
+ import { InjectModel } from '@nestjs/mongoose';
3
+ import { Model } from 'mongoose';
4
+
5
+ import { TournamentManyTablesRoom, TournamentManyTablesRoomDocument } from '../';
6
+
7
+ @Injectable()
8
+ export class TournamentManyTablesRoomsRepository {
9
+ constructor (@InjectModel(TournamentManyTablesRoom.name) private roomModel: Model<TournamentManyTablesRoomDocument>) {
10
+ }
11
+
12
+ async findRooms (gameType: string): Promise<Array<TournamentManyTablesRoomDocument>> {
13
+ return this.roomModel
14
+ .find({ gameType })
15
+ .exec();
16
+ }
17
+ }
@@ -0,0 +1,17 @@
1
+ import { Injectable } from '@nestjs/common';
2
+ import { InjectModel } from '@nestjs/mongoose';
3
+ import { Model } from 'mongoose';
4
+
5
+ import { TournamentOneTableRoom, TournamentOneTableRoomDocument } from '../';
6
+
7
+ @Injectable()
8
+ export class TournamentOneTableRoomsRepository {
9
+ constructor (@InjectModel(TournamentOneTableRoom.name) private roomModel: Model<TournamentOneTableRoomDocument>) {
10
+ }
11
+
12
+ async findRooms (gameType: string): Promise<Array<TournamentOneTableRoomDocument>> {
13
+ return this.roomModel
14
+ .find({ gameType })
15
+ .exec();
16
+ }
17
+ }
@@ -0,0 +1,21 @@
1
+ import { Injectable } from '@nestjs/common';
2
+ import { InjectModel } from '@nestjs/mongoose';
3
+ import { Model } from 'mongoose';
4
+
5
+ import { TournamentResult, TournamentResultDocument, User } from '../';
6
+
7
+ @Injectable()
8
+ export class TournamentResultRepository {
9
+ constructor (@InjectModel(TournamentResult.name) private resultModel: Model<TournamentResultDocument>) {
10
+ }
11
+
12
+ async findByTournamentId (tournamentId: string): Promise<TournamentResultDocument | null> {
13
+ return this.resultModel
14
+ .findOne({ tournamentId })
15
+ .exec();
16
+ }
17
+
18
+ async createResult (result: Partial<TournamentResult>): Promise<TournamentResult> {
19
+ return this.resultModel.create(result);
20
+ }
21
+ }
@@ -0,0 +1,43 @@
1
+ import { Prop, Schema, SchemaFactory, Virtual } from '@nestjs/mongoose';
2
+ import { Document, HydratedDocument } from 'mongoose';
3
+
4
+ export type SimpleRoomDocument = HydratedDocument<SimpleRoom>;
5
+
6
+ @Schema({ collection: 'simple_rooms' })
7
+ export class SimpleRoom {
8
+ @Virtual({
9
+ get: function (this: Document) {
10
+ return this._id.toString();
11
+ },
12
+ })
13
+ readonly roomId: string;
14
+
15
+ @Prop({ type: Object })
16
+ title: Record<string, string>;
17
+
18
+ @Prop({ type: Object })
19
+ subtitle: Record<string, string>;
20
+
21
+ @Prop()
22
+ tableSize: number;
23
+
24
+ @Prop()
25
+ bet: number;
26
+
27
+ @Prop()
28
+ ticketPrice: number;
29
+
30
+ @Prop()
31
+ roomType: string;
32
+
33
+ @Prop()
34
+ gameType: string;
35
+
36
+ @Prop()
37
+ rulesType: string;
38
+
39
+ @Prop()
40
+ deckType?: string;
41
+ }
42
+
43
+ export const SimpleRoomSchema = SchemaFactory.createForClass(SimpleRoom);
@@ -0,0 +1,70 @@
1
+ import { Prop, Schema, SchemaFactory, Virtual } from '@nestjs/mongoose';
2
+ import { Document, HydratedDocument } from 'mongoose';
3
+
4
+ export type TournamentManyTablesRoomDocument = HydratedDocument<TournamentManyTablesRoom>;
5
+
6
+ export interface IParticipant {
7
+ userId: string;
8
+ userName: string;
9
+ userAvatarUrl: string;
10
+ }
11
+
12
+ @Schema({ collection: 'tournament_many_tables_rooms' })
13
+ export class TournamentManyTablesRoom {
14
+ @Virtual({
15
+ get: function (this: Document) {
16
+ return this._id.toString();
17
+ },
18
+ })
19
+ readonly roomId: string;
20
+
21
+ @Prop({ type: Object })
22
+ title: Record<string, string>;
23
+
24
+ @Prop({ type: Object })
25
+ subtitle: Record<string, string>;
26
+
27
+ @Prop()
28
+ tableSize: number;
29
+
30
+ @Prop()
31
+ bet: number;
32
+
33
+ @Prop()
34
+ ticketPrice: number;
35
+
36
+ @Prop()
37
+ roomType: string;
38
+
39
+ @Prop()
40
+ gameType: string;
41
+
42
+ @Prop()
43
+ rulesType: string;
44
+
45
+ @Prop()
46
+ deckType?: string;
47
+
48
+ @Prop()
49
+ createDate: Date;
50
+
51
+ @Prop()
52
+ startDate: Date;
53
+
54
+ @Prop({ type: Object })
55
+ description: Record<string, string>;
56
+
57
+ @Prop()
58
+ participants: Array<IParticipant>;
59
+
60
+ @Prop()
61
+ maxParticipants: number;
62
+
63
+ @Prop()
64
+ status: string;
65
+
66
+ @Prop()
67
+ type: string;
68
+ }
69
+
70
+ export const TournamentManyTablesRoomSchema = SchemaFactory.createForClass(TournamentManyTablesRoom);
@@ -0,0 +1,43 @@
1
+ import { Prop, Schema, SchemaFactory, Virtual } from '@nestjs/mongoose';
2
+ import { Document, HydratedDocument } from 'mongoose';
3
+
4
+ export type TournamentOneTableRoomDocument = HydratedDocument<TournamentOneTableRoom>;
5
+
6
+ @Schema({ collection: 'tournament_one_table_rooms' })
7
+ export class TournamentOneTableRoom {
8
+ @Virtual({
9
+ get: function (this: Document) {
10
+ return this._id.toString();
11
+ },
12
+ })
13
+ readonly roomId: string;
14
+
15
+ @Prop({ type: Object })
16
+ title: Record<string, string>;
17
+
18
+ @Prop({ type: Object })
19
+ subtitle: Record<string, string>;
20
+
21
+ @Prop()
22
+ tableSize: number;
23
+
24
+ @Prop()
25
+ bet: number;
26
+
27
+ @Prop()
28
+ ticketPrice: number;
29
+
30
+ @Prop()
31
+ roomType: string;
32
+
33
+ @Prop()
34
+ gameType: string;
35
+
36
+ @Prop()
37
+ rulesType: string;
38
+
39
+ @Prop()
40
+ deckType?: string;
41
+ }
42
+
43
+ export const TournamentOneTableRoomSchema = SchemaFactory.createForClass(TournamentOneTableRoom);
@@ -0,0 +1,36 @@
1
+ import { Prop, Schema, SchemaFactory, Virtual } from '@nestjs/mongoose';
2
+ import { Document, HydratedDocument } from 'mongoose';
3
+
4
+ export type TournamentResultDocument = HydratedDocument<TournamentResult>;
5
+
6
+ export interface IWinner {
7
+ userId: string;
8
+ userName: string;
9
+ userAvatarUrl: string;
10
+ profit: number;
11
+ rank: number;
12
+ }
13
+
14
+ @Schema({ collection: 'tournament_results' })
15
+ export class TournamentResult {
16
+ @Virtual({
17
+ get: function (this: Document) {
18
+ return this._id.toString();
19
+ },
20
+ })
21
+ readonly resultId: string;
22
+
23
+ @Prop()
24
+ tournamentId: String;
25
+
26
+ @Prop()
27
+ gameType: String;
28
+
29
+ @Prop()
30
+ winners: Array<IWinner>;
31
+
32
+ @Prop()
33
+ createDate: Date;
34
+ }
35
+
36
+ export const TournamentResultSchema = SchemaFactory.createForClass(TournamentResult);