diff --git a/backend/fixtures/applications.json b/backend/fixtures/applications.json index 7f107445..a1ddb07d 100644 --- a/backend/fixtures/applications.json +++ b/backend/fixtures/applications.json @@ -3,8 +3,8 @@ "name": "Bolle Bollesen", "phone_number": "+6969696969", "email": "bolle@bolle.no", - "text": "Jeg forsøker å søke til Sprint og Blits", - "committees": ["6", "44"], + "text": "Jeg forsøker å søke til Sprint", + "committees": [6], "submitted_date": "2022-02-26T16:49:27.005Z" }, { @@ -12,15 +12,15 @@ "phone_number": "+420420420", "email": "Navn@Navnesen.no", "text": "Jeg forsøker å søke til Event", - "committees": ["74"], + "committees": [74], "submitted_date": "2022-02-23T16:49:27.005Z" }, { "name": "Cris P Bacon", "phone_number": "+123456789", "email": "Bacon@IsGoodForMe.no", - "text": "Jeg forsøker å søke til Event og Blits", - "committees": ["74", "44"], + "text": "Jeg forsøker å søke til Blits", + "committees": [44], "submitted_date": "2022-02-19T16:49:27.005Z" }, { @@ -28,7 +28,7 @@ "phone_number": "+987654321", "email": "Olle@Bolle.no", "text": "Jeg forsøker å søke til Event, Blits og Sprint", - "committees": ["74", "44", "6"], + "committees": [74, 44, 6], "submitted_date": "2022-02-22T16:49:27.005Z" } ] diff --git a/backend/models/Application.ts b/backend/models/Application.ts index 7c5014a7..fee9aa7b 100644 --- a/backend/models/Application.ts +++ b/backend/models/Application.ts @@ -6,7 +6,7 @@ interface ApplicationI { email: string text: string submitted_date: Date - committees: [{ type: mongoose.Schema.Types.Number; ref: 'Committee' }] + committees: number[] } const ApplicationModel = mongoose.model( @@ -32,7 +32,7 @@ const ApplicationModel = mongoose.model( committees: { type: [ { - type: mongoose.Schema.Types.Number, + type: Number, ref: 'Committee', required: true, }, diff --git a/backend/models/Committee.ts b/backend/models/Committee.ts index 741c6b7d..acc992ec 100644 --- a/backend/models/Committee.ts +++ b/backend/models/Committee.ts @@ -1,21 +1,18 @@ -import mongoose, { ObjectId } from 'mongoose' +import mongoose from 'mongoose' interface CommitteeI { - _id: ObjectId + _id: Number name: string slug: string } const CommitteeModel = mongoose.model( 'Committee', - new mongoose.Schema( - { - _id: { type: mongoose.Schema.Types.Number, required: true }, - name: { type: String, required: true }, - slug: { type: String, required: true }, - }, - { _id: false } - ) + new mongoose.Schema({ + _id: { type: Number, required: true }, + name: { type: String, required: true }, + slug: { type: String, required: true }, + }) ) export { CommitteeModel }