I need help updating an array in my database which currently doesn't have any fields. Can anyone suggest a way to add fields to the existing empty array?
Schema
const UserSchema = new Schema({
User: [{
Name:{
type: String,
},
Email:{
type: String,
},
}]
})
The array is currently saved in the database but it's empty like this
saved database
"id": 101,
"User":[],
Below is the code I've used to update the array
User.update({id: 101,},
{
$push:{
user:{
Name: "Kevin",
Email: "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="266d43504f4866414b474f4a0845494b">[email protected]</a>",
},
}
},(err, data)=>{
console.log(data)
})
However, upon running this code, the array doesn't seem to update. Can anyone provide guidance on how to resolve this issue?