I want to push an object inside an object that is inside an array. To make it clearer, here is the structure of what my mongoose model is like this:
username: {
type: String,
min: 1,
required:true,
},
password: {
type: String,
required: true
},
folders:[
{
title:String,
files:[{
fileID: String,
type: String
}]
}
]
each folder would automatically get an object id. What I want to do is to add an object to the specific folder's files. The files is an array which is where I would push the object. I tried adding it using something like this:
await User.findOne({username:username}, {$push:
{[folderID.files]: [ {title:'title', type:'type'} ]}
})
but it doesn't work