Skip to content

Commit 33190d7

Browse files
committed
new content adding recup to total ok
1 parent ac4d6cd commit 33190d7

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

models/content.model.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const contentSchema = new Schema({
66
enum: [
77
"book",
88
"comic",
9-
"film",
9+
"movie",
1010
"podcast",
1111
"series",
1212
"song",
@@ -18,14 +18,15 @@ const contentSchema = new Schema({
1818
author: [{ type: String, required: true }],
1919
keywords: [{ type: String }],
2020
mediaUrl: { type: String, required: true }, // content needs media xd
21-
// // here comes cloudinary... just in case
21+
// // just in case
2222
// media: {
2323
// url: { type: String }, // cloudinary URL
2424
// publicId: { type: String }, // cloudinary publicId
2525
// format: { type: String } // format could be useful
2626
// },
2727
totalRecommendations: { type: Number, default: 0 },
28-
firstRecommendationCreator: { type: Schema.Types.ObjectId, ref: "User", required: true }
28+
firstRecommendationCreator: { type: Schema.Types.ObjectId, ref: "User", required: true },
29+
firstRecupByContentCreator: { type: Boolean, default: false }
2930
},
3031
{
3132
timestamps: true

routes/recommendation.routes.js

+5
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ router.post("/new-content", verifyToken, async (req, res, next) => {
7777
recText: req.body.recText
7878
})
7979

80+
// increment +1 totalRecommendations in content
81+
await Content.findByIdAndUpdate(newContent._id, {
82+
$inc: { totalRecommendations: 1 }
83+
})
84+
8085
// add the new rec to the createdRecs user array property
8186
await User.findByIdAndUpdate(req.payload._id, {
8287
$push: { createdRecs: newRec._id }

0 commit comments

Comments
 (0)