Mongoose schema nested object

Hello, this is my code:

const NewUserSchema = mongoose.Schema({
    name:{type:String, required:true},
    password:{type:String, required:true},
    email:{type:String, required:true},
    friends: {type:Array, default: undefined},
    posts:{type:Object, default: {}}

})

How can I create a different schema for posts property? I want it to receive several properties, such as head,body,image and so on

Actually no, I wanted posts to be an array of objects where each object would be a single post that contains those properties

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.