Editing array inside of the array with mongoose

let PostSchema = mongoose.Schema({
    content: {type:String,required:true},
    likes: {type:Array, default: []},
    comments: {type:Array, default: []},
    time: {type:Date, default: new Date().getTime().toString()}

const NewUserSchema = mongoose.Schema({
    name:{type:String, required:true},
    password:{type:String, required:true},
    email:{type:String, required:true},
    friends: {type:Array, default: []},
    friendRequests: {type:Array,default: []}

Hello, how can I now find and update the specific post inside of the posts array of my NewUserSchema?

Sensible thing would be to give each post an ID, then in the user schema’s posts field, just have an array of ids. Then to find a specific post you just ask for a specific post

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