crazy-odds-bet-shared 1.0.45 → 1.0.46

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.
package/models/fixture.js CHANGED
@@ -23,8 +23,10 @@ const fixtureSchema = new Schema(
23
23
  ...createBaseSchema(),
24
24
  sportId: { type: String, required: true, ref: 'Sport' },
25
25
  competitionId: { type: String, required: true, ref: 'Competition' },
26
- homeTeamId: { type: String, required: true, ref: 'Team' },
27
- awayTeamId: { type: String, required: true, ref: 'Team' },
26
+ homeTeamId: { type: String, required: false, ref: 'Team' },
27
+ awayTeamId: { type: String, required: false, ref: 'Team' },
28
+ firstPlayerId: { type: String, required: false, ref: 'Player' },
29
+ secondPlayerId: { type: String, required: false, ref: 'Player' },
28
30
  name: { type: String, required: true },
29
31
  slug: { type: String, unique: true, sparse: true },
30
32
  scheduledAt: { type: Date, required: true },
@@ -45,6 +47,8 @@ fixtureSchema.index({ sportId: 1 });
45
47
  fixtureSchema.index({ competitionId: 1 });
46
48
  fixtureSchema.index({ homeTeamId: 1 });
47
49
  fixtureSchema.index({ awayTeamId: 1 });
50
+ fixtureSchema.index({ firstPlayerId: 1 });
51
+ fixtureSchema.index({ secondPlayerId: 1 });
48
52
  fixtureSchema.index({ scheduledAt: 1 });
49
53
  fixtureSchema.index({ status: 1 });
50
54
  fixtureSchema.index({ scheduledAt: 1, status: 1 });
@@ -78,6 +82,20 @@ fixtureSchema.virtual('awayTeam', {
78
82
  justOne: true
79
83
  });
80
84
 
85
+ fixtureSchema.virtual('firstPlayer', {
86
+ ref: 'Player',
87
+ localField: 'firstPlayerId',
88
+ foreignField: '_id',
89
+ justOne: true
90
+ });
91
+
92
+ fixtureSchema.virtual('secondPlayer', {
93
+ ref: 'Player',
94
+ localField: 'secondPlayerId',
95
+ foreignField: '_id',
96
+ justOne: true
97
+ });
98
+
81
99
  // Static methods
82
100
  fixtureSchema.static('findBySlug', function (slug) {
83
101
  return this.findOne({ slug });
@@ -123,6 +141,12 @@ fixtureSchema.static('findByTeam', function (teamId) {
123
141
  }).sort({ scheduledAt: 1 });
124
142
  });
125
143
 
144
+ fixtureSchema.static('findByPlayer', function (playerId) {
145
+ return this.find({
146
+ $or: [{ firstPlayerId: playerId }, { secondPlayerId: playerId }]
147
+ }).sort({ scheduledAt: 1 });
148
+ });
149
+
126
150
  fixtureSchema.static('findUpcoming', function (limit = 20) {
127
151
  return this.find({
128
152
  scheduledAt: { $gte: new Date() },
package/models/player.js CHANGED
@@ -11,7 +11,7 @@ const playerSchema = new Schema(
11
11
  {
12
12
  ...createBaseSchema(),
13
13
  sportId: { type: String, required: true, ref: 'Sport' },
14
- teamId: { type: String, required: true, ref: 'Team' },
14
+ teamId: { type: String, required: false, ref: 'Team' },
15
15
  fullName: { type: String, required: true },
16
16
  firstName: { type: String },
17
17
  lastName: { type: String },
package/models/sport.js CHANGED
@@ -13,6 +13,12 @@ const sportSchema = new Schema(
13
13
  name: { type: String, required: true },
14
14
  slug: { type: String, unique: true, sparse: true },
15
15
  displayName: { type: String, required: true },
16
+ category: {
17
+ type: String,
18
+ required: true,
19
+ enum: ['team', 'individual'],
20
+ default: 'team'
21
+ },
16
22
  isActive: { type: Boolean, default: true },
17
23
  externalRefs: { type: Schema.Types.Mixed, default: {} }
18
24
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "crazy-odds-bet-shared",
3
- "version": "1.0.45",
3
+ "version": "1.0.46",
4
4
  "description": "Shared MongoDB models and utilities for odds project",
5
5
  "main": "index.js",
6
6
  "exports": {