forked from Prompt-Hash-Stellar/prompt-hash
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReview.ts
More file actions
40 lines (37 loc) · 773 Bytes
/
Copy pathReview.ts
File metadata and controls
40 lines (37 loc) · 773 Bytes
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
import mongoose from "mongoose";
const reviewSchema = new mongoose.Schema(
{
promptId: {
type: String,
required: true,
index: true,
},
userAddress: {
type: String,
required: true,
lowercase: true,
index: true,
},
rating: {
type: Number,
required: true,
min: 1,
max: 5,
},
text: {
type: String,
default: "",
trim: true,
maxlength: 2000,
},
verified: {
type: Boolean,
default: false,
},
},
{ timestamps: true },
);
// One review per user per prompt
reviewSchema.index({ promptId: 1, userAddress: 1 }, { unique: true });
const Review = mongoose.models.Review || mongoose.model("Review", reviewSchema);
export default Review;