Updating
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import { Model, Schema, Types, model, models } from "mongoose";
|
||||
|
||||
export interface GameDocument {
|
||||
gameDate: Date;
|
||||
activePlayerIds: Types.ObjectId[];
|
||||
startingPitcherId?: Types.ObjectId | null;
|
||||
notes?: string;
|
||||
createdAt?: Date;
|
||||
updatedAt?: Date;
|
||||
}
|
||||
|
||||
const gameSchema = new Schema<GameDocument>(
|
||||
{
|
||||
gameDate: { type: Date, required: true, unique: true, index: true },
|
||||
activePlayerIds: [{ type: Schema.Types.ObjectId, ref: "Player" }],
|
||||
startingPitcherId: { type: Schema.Types.ObjectId, ref: "Player", default: null },
|
||||
notes: { type: String, default: "" }
|
||||
},
|
||||
{ timestamps: true }
|
||||
);
|
||||
|
||||
export const GameModel = (models.Game as Model<GameDocument>) || model<GameDocument>("Game", gameSchema);
|
||||
Reference in New Issue
Block a user