Fixed Schemas.

This commit is contained in:
BurnyLlama 2021-09-26 18:06:31 +02:00
parent 6654aac896
commit e7a1e768ee
3 changed files with 14 additions and 20 deletions

View File

@ -1,11 +1,10 @@
import { Schema } from 'mongoose'
import Level from './Level.js'
import Player from './Player.js'
import mongoose from 'mongoose'
const Finish = new Schema({
map: Level,
const Finish = new mongoose.Schema({
map: { type: mongoose.Schema.ObjectId, ref: 'Level' },
time: Number,
time: Date,
players: [Player]
players: [{ type: mongoose.Schema.ObjectId, ref: 'Player' }]
})
export default Finish
export default mongoose.model("Finish", Finish)

View File

@ -1,14 +1,12 @@
import { Schema } from 'mongoose'
import Finish from './Finishes.js'
import mongoose from 'mongoose'
const Level = new Schema({
const Level = new mongoose.Schema({
name: String,
mapper: String,
release: Date,
category: String,
rating: Number,
awardPoints: Number,
finishes: [Finish]
awardPoints: Number
})
export default Level
export default mongoose.model("Level", Level)

View File

@ -1,13 +1,10 @@
import { Schema } from 'mongoose'
import Level from './Level.js'
import mongoose from 'mongoose'
const Player = new Schema({
const Player = new mongoose.Schema({
name: String,
points: Number,
rankPoints: Number,
teamPoints: Number,
finishedMaps: [Level],
favouritePartners: [Player]
teamPoints: Number
})
export default Player
export default mongoose.model("Player", Player)