aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreug-vs <eug-vs@keemail.me>2020-06-28 15:40:53 +0300
committereug-vs <eug-vs@keemail.me>2020-06-28 15:41:41 +0300
commite63122d84c65f30eb1e063504e7f16a05eb769f1 (patch)
treef4b31dc8d8c3c42467489a13b696db9145454795
parent8baf96be5ea7880cebe3aeda733b9196950be434 (diff)
downloadwhich-api-e63122d84c65f30eb1e063504e7f16a05eb769f1.tar.gz
feat: create Feedback model
-rw-r--r--models/feedback/feedback.model.ts5
-rw-r--r--models/feedback/feedback.schema.ts28
2 files changed, 33 insertions, 0 deletions
diff --git a/models/feedback/feedback.model.ts b/models/feedback/feedback.model.ts
new file mode 100644
index 0000000..b2ec4b5
--- /dev/null
+++ b/models/feedback/feedback.model.ts
@@ -0,0 +1,5 @@
+import { Model, model, Types } from 'mongoose';
+import { FeedbackSchema, feedbackSchema } from './feedback.schema';
+
+export default model<FeedbackSchema, Model<FeedbackSchema>>('Feedback', feedbackSchema);
+
diff --git a/models/feedback/feedback.schema.ts b/models/feedback/feedback.schema.ts
new file mode 100644
index 0000000..a0844d6
--- /dev/null
+++ b/models/feedback/feedback.schema.ts
@@ -0,0 +1,28 @@
+import { Document, Schema, Types } from 'mongoose';
+
+export interface FeedbackSchema extends Document {
+ contents: string;
+ authorId: string;
+ score: number;
+ version: string;
+ createdAt: Date;
+}
+
+export const FeedbackSchema = new Schema({
+ contents: String,
+ authorId: {
+ type: Types.ObjectId,
+ required: true,
+ ref: 'User'
+ },
+ score: {
+ type: Number,
+ required: true
+ },
+ version: {
+ type: String,
+ match: /^v\d+\.\d+\.\d+$/,
+ required: true
+ }
+}, { timestamps: true });
+