From bb4c4cc8307fd60355eafa82ea5f38967556e716 Mon Sep 17 00:00:00 2001 From: Allison67 <96998345+Allison67@users.noreply.github.com> Date: Tue, 5 Dec 2023 23:58:25 -0500 Subject: [PATCH] Create Event.js --- back-end/models/Event.js | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 back-end/models/Event.js diff --git a/back-end/models/Event.js b/back-end/models/Event.js new file mode 100644 index 0000000..458dfd7 --- /dev/null +++ b/back-end/models/Event.js @@ -0,0 +1,34 @@ +const mongoose = require("mongoose"); +const Schema = mongoose.Schema; +const { User } = require("./User"); +const { Expense } = require("./Expense"); + +const eventSchema = new Schema({ + name: { + type: String, + required: true, + }, + description: String, + date: { + type: Date, + required: true, + }, + participants: [ + { + type: Schema.Types.ObjectId, + ref: "User", + }, + ], + expenses: [ + { + type: Schema.Types.ObjectId, + ref: "Expense", + }, + ], +}); + +const Event = mongoose.model("Event", eventSchema); + +module.exports = { + Event, +};