hi @shohanr,
thanks for replying,
my schema is:
import { Schema } from 'mongoose';
export const REVIEW_STATUSES = {
submitted: 'submitted',
approved: 'approved',
rejected: 'rejected',
deleted: 'deleted',
};
export const REVIEW_MEDIA_TYPES = {
image: 'image',
};
export const REVIEW_METRICS = {
general: 'general',
};
const schema = Schema(
{
status: { type: String, enum: Object.values(REVIEW_STATUSES) },
reviewer: {
userId: String,
buyerSid: String,
name: String,
email: String,
},
subject: {
makerSid: { type: String, index: true },
makerName: String,
makerContactDetails: String,
orderSid: String,
item: {
name: String,
popSid: { type: String, index: true },
productSid: String,
variantSid: String,
},
},
content: {
title: String,
details: String,
media: [
{
type: { type: String, enum: Object.values(REVIEW_MEDIA_TYPES) },
publicId: String,
},
],
metrics: {
general: { rating: Number }
},
mediaUsagePermitted: Boolean,
},
source: String,
reviewedAt: Date,
createdAt: Date,
modifiedAt: Date,
deletedAt: Date,
}
);
export default schema;
and a record is:
{
"_id" : ObjectId("62fd312ef85b04d573c1459c"),
"subject" : {
"item" : {
"popSid" : "PHJxNdzmTt",
"productSid" : "PRDHJxNdzmTt"
},
"makerSid" : "MB1BufmTtZ",
"orderSid" : "ORD2106-WT724K"
},
"status" : "approved",
"reviewer" : {
"buyerSid" : "BBJ7GDy2GP",
"userId" : "auth0|629d903d26a937006f7095d2"
},
"content" : {
"media" : [
{
"_id" : ObjectId("6305ec8790aca087647d02c8"),
"type" : "image",
"publicId" : "wescover-image-store/j3e4hosgxhfgd9crblop"
},
{
"_id" : ObjectId("6305ec8790aca087647d02c7"),
"type" : "image",
"publicId" : "wescover-dev-uploads/bqox1b3oielf6hksotew"
}
],
"metrics" : {
"general" : {
"rating" : NumberInt(5)
}
}
},
"reviewedAt" : ISODate("2022-08-17T18:19:26.173+0000"),
"createdAt" : ISODate("2022-08-17T18:19:26.173+0000"),
"modifiedAt" : ISODate("2022-08-29T11:35:13.866+0000"),
"__v" : NumberInt(0),
"deletedAt" : ISODate("2022-08-28T08:41:23.635+0000")
}
thanks in advance,
nimrod