Skip to content
Snippets Groups Projects
post.js 891 B
Newer Older
  • Learn to ignore specific revisions
  • Ludvig Damberg's avatar
    Ludvig Damberg committed
    const mongoose = require('mongoose')
    const userModel = require('./user')
    
    const postSchema = new mongoose.Schema({
        name: {
            type: String,
            required: true
        },
        recipe: {
            type: [String],
            required: false
        },
        description: {
            type: String,
            required: true
        },
        author:{
            type: mongoose.Schema.Types.ObjectId,
            ref:"user"
        },
        profile_picture: {
            type: String,
            required: true
        },
        profile_name: {
            type: String,
            required: true
        },
        upvotes: {
            type: [String],
            required: false
        },
        comments: {
            type: [mongoose.Schema.Types.ObjectId],
            ref:"comment",
            required: false
        },
        photo: {
            type: String,
            required: true
        }
    
    
    })
    
    const postModel = mongoose.model("Post", postSchema)
    
    module.exports = postModel