Skip to content
Open
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
33 changes: 33 additions & 0 deletions src/models/Review.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import db from '../db';

export const reviewSchema = db.Schema({
tutor: {
type: db.Schema.Types.ObjectId,
ref: 'User',
required: true,
},
learner: {
type: db.Schema.Types.ObjectId,
ref: 'User',
required: true,
},

userRating: [{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need for array.

reviewedName: {type: String, default: ''},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

names can be retrieved from the reviewer and reviewee models, no need to store them directly.

reviewerFullname: {type: String, default: ''},
userRating: {type: Number, default: 0},
userReview: {type: String, default: ''}
}],

ratingNumber: [Number],
ratingSum: {type: Number, default: 0},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need for sum here


});

reviewSchema.methods.toJSON = function () {
const review = this.toObject();
delete review.__v;
return review;
};

export default db.model('Review', reviewSchema);