Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: application and committee types #24

Merged
merged 2 commits into from
Mar 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions backend/fixtures/applications.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,32 @@
"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"
},
{
"name": "Navn Navnesen",
"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"
},
{
"name": "Olle Bolle",
"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"
}
]
4 changes: 2 additions & 2 deletions backend/models/Application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<ApplicationI>(
Expand All @@ -32,7 +32,7 @@ const ApplicationModel = mongoose.model<ApplicationI>(
committees: {
type: [
{
type: mongoose.Schema.Types.Number,
type: Number,
ref: 'Committee',
required: true,
},
Expand Down
17 changes: 7 additions & 10 deletions backend/models/Committee.ts
Original file line number Diff line number Diff line change
@@ -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<CommitteeI>(
'Committee',
new mongoose.Schema<CommitteeI>(
{
_id: { type: mongoose.Schema.Types.Number, required: true },
name: { type: String, required: true },
slug: { type: String, required: true },
},
{ _id: false }
)
new mongoose.Schema<CommitteeI>({
_id: { type: Number, required: true },
name: { type: String, required: true },
slug: { type: String, required: true },
})
)

export { CommitteeModel }
Expand Down