Am trying to learn full-stack development using the MERN approach. I have a situation where when a user adds the item to its watchlist, which has the following filed
movie id
movie poster(an image)
movie name
released date
I want to store this to MongoDB Atlast using mongoose query and node.js
and such that when a user clicks on remove button on front-end it gets deleted.
However I know I have to use get, post, put, patch, delete APIs respectively. But my concern is, how is this possible or can be achieved when you have image type in your schema?
In short, how can I store the data which has an image for example below card?
Thanks for your help and your advice. Please see the Schema code below which am trying please do correct me where am wrong also advice me on related tutorial,
//on watchlistSchema.js
import { express } from "express";
import { mongoose } from "mongoose";
const watchlistSchema = mongoose.Schema({
name: {
type: String,
},
image: {
type: Buffer,
},
});
const watchlistItem = mongoose.model("newWatchlist", newWatchlistSchema);
module.exports = watchlistItem;
//on route.js
const watchlistItem = require("../model/watchlistSchema");
router.post("/watchlistitem", (req, res) => {
res.send("hi ");
console.log("watchlist item is here");
});
Trying to test on POSTMAN