-
Notifications
You must be signed in to change notification settings - Fork 0
/
userToBallotSchema.ts
31 lines (29 loc) · 1.01 KB
/
userToBallotSchema.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { Schema, model, models } from "mongoose";
const userToBallotSchema = new Schema({
userId: {
type: "string",
required: [true, "User Id required to save relation to db."]
},
relation: Array<{
ballot_id: {
type: "string",
required: [true, "Ballot Id is required to save relation in db."]
},
type: {
binary: {
type: boolean,
required: [true, "Binary boolean value required to save relation in db."]
},
candidate: {
type: "string",
required: [true, "candidate userId is required to save relation in db."]
},
vote: {
type: "string",
required: [true, "vote selection is required to save relation in db."]
},
},
}>
});
const UserToBallotSchema = models.UserToBallotSchema || model('UserToBallotSchema', userToBallotSchema, 'user-ballot');
export default UserToBallotSchema;