-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsurveyAnswerModel.js
More file actions
43 lines (35 loc) · 1.12 KB
/
surveyAnswerModel.js
File metadata and controls
43 lines (35 loc) · 1.12 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
import { Model } from 'objection';
import { ModelNames } from '@utils/constants';
const path = require('path');
export class SurveyAnswerModel extends Model {
static get tableName() {
return ModelNames.MODEL_NAME__SURVEY_ANSWER;
}
async $beforeInsert() {
this.createdAt = new Date().toISOString();
this.updatedAt = new Date().toISOString();
}
async $beforeUpdate() {
this.updatedAt = new Date().toISOString();
}
static get relationMappings() {
return {
question: {
relation: Model.BelongsToOneRelation,
modelClass: path.resolve(__dirname, './surveyQuestionModel.js'),
join: {
to: `${ModelNames.MODEL_NAME__SURVEY_QUESTION}.id`,
from: `${ModelNames.MODEL_NAME__SURVEY_ANSWER}.surveyQuestionId`,
},
},
partner: {
relation: Model.BelongsToOneRelation,
modelClass: path.resolve(__dirname, '../partnerProfile/partnerProfileModel.js'),
join: {
to: `${ModelNames.MODEL_NAME__PARTNER_PROFILE}.id`,
from: `${ModelNames.MODEL_NAME__SURVEY_ANSWER}.partnerProfileId`,
},
},
};
}
}