Du kan använda $map-aggregationsoperatorn
för att tillämpa $dateFromString
till varje element i arrayen:
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"
}
}
}
}
}])