Anda dapat menggunakan $operator agregasi peta
untuk menerapkan $dateFromString
ke setiap elemen dalam larik:
db.test.aggregate([{
"$project": {
"ticker": 1,
"currency": 1,
"daily": {
"$map": {
"input": "$daily",
"in": {
"timestamp": {
"$dateFromString": {
"dateString": '$$this.timestamp',
"format": '%Y-%m-%d'
}
},
"open": "$$this.open",
"high": "$$this.high",
"low": "$$this.low",
"close": "$$this.close",
"volume": "$$this.volume"
}
}
}
}
}])