Helo @Bushra_Rashid_Baig, Welcome,
"likedBy": [
{
"id": {
"type": mongoose.ObjectId,
"ref": "User"
},
"likedAt": Date
}
]
- Migrate your data into collection
- The $$NOW will set current date, you can pass external date if you want.
db.collection.updateMany({},
[
{
$set: {
likedBy: {
$map: {
input: "$likedBy",
in: {
id: "$$this",
likedAt: "$$NOW"
}
}
}
}
}
])
Check the query in dummy data before executing in live database!