最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

express - Storing and fetching multiple images for a blog app made using MERN stack - Stack Overflow

programmeradmin3浏览0评论

I was making this application using MERN stack. But what I want to know is, how are multiple images persisted in my mongoDB atlas, and how do I fetch them sequentially. I came up with an idea to store the filenames with in a field called images which is an Array. but I got stuck on fetching those sequentially, like one post can have multiple images. Any suggestions on how i should implement this feature I was using react quill as my text editor.

import { Schema } from "mongoose";
import mongoose from "mongoose";
const PostSchema = new Schema(
  {
    photo: {
      type: String,
      required: false,
    },
    title: {
      type: String,
      required: true,
    },
    desc: {
      type: String,
      required: true,
    },
    username: {
      type: String,
      required: true,
    },
    categories: {
      type: Array,
      required: false,
    },
  },
  { timestamps: true }
);
export default mongoose.model("Post", PostSchema);

发布评论

评论列表(0)

  1. 暂无评论