Add endpoint for fetching my-team/players

This commit is contained in:
2020-11-04 23:09:36 -06:00
parent 19567dcfb0
commit 33c37f6855
4 changed files with 23 additions and 5 deletions

View File

@@ -67,11 +67,12 @@ class Player extends Model {
async to_api() {
return {
player_number: this.player_number,
player_name: this.player_name,
player_position: this.player_position,
team_name: this.team_name,
image_url: this.image_url,
number: this.player_number,
name: this.full_name,
position: this.fantasy_position,
team_name: this.patch_data.patch_team_name,
image: this.photo_url,
stats: {}, // TODO - populate some stats!
}
}
}

View File

@@ -50,6 +50,15 @@ class Team extends Model {
return new_team
}
async players() {
const Player = this.models.get('Player')
return Player.find({
_id: {
$in: this.player_ids.map(x => Player.to_object_id(x))
}
})
}
async to_api() {
const User = this.models.get('auth:User')