refactor(db/models): remove existence guard/check from models
This commit is contained in:
parent
b5454e9363
commit
b21aab4940
@ -57,13 +57,20 @@ CommentSchema.virtual("story", {
|
||||
foreignField: "_id",
|
||||
justOne: true,
|
||||
});
|
||||
|
||||
CommentSchema.pre("findOne", populate("replies"))
|
||||
.pre("find", populate("replies"))
|
||||
.pre("findOne", populate("commentAuthor"))
|
||||
.pre("find", populate("commentAuthor"))
|
||||
.pre("findOne", populateSelected("replyingTo", "-replies"))
|
||||
.pre("find", populateSelected("replyingTo", "-replies"));
|
||||
const modelName = "Review";
|
||||
CommentSchema
|
||||
// .pre("findOne", populateSelected("replyingTo", modelName, "-replies -author"))
|
||||
// .pre("find", populateSelected("replyingTo", modelName, "-replies -author"))
|
||||
.pre("findOne", populate("replies", modelName))
|
||||
.pre("find", populate("replies", modelName))
|
||||
.pre(
|
||||
"findOne",
|
||||
populateSelected("author", "User", "profile username _id blocked"),
|
||||
)
|
||||
.pre(
|
||||
"find",
|
||||
populateSelected("author", "User", "profile username _id blocked"),
|
||||
);
|
||||
|
||||
hasMigrated &&
|
||||
!mongoose.models.Review &&
|
||||
@ -71,7 +78,7 @@ hasMigrated &&
|
||||
|
||||
export const Review: Model<IReview> =
|
||||
/* mongoose.models.Review || */ mongoose.model(
|
||||
"Review",
|
||||
modelName,
|
||||
CommentSchema,
|
||||
"reviews",
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user