Database

[{_id:0,source:"red",dt:new Date("2020-05-18T14:10:30Z"),temp:23,},{_id:1,source:"red",dt:new Date("2021-03-20T11:30:05Z"),temp:17,},{_id:2,source:"blue",dt:new Date("2021-01-11T06:31:15Z"),temp:-2,},{_id:3,source:"blue",dt:new Date("2020-02-08T13:13:23Z"),temp:31,},{_id:4,source:"strawberry",dt:new Date("2019-05-18T16:09:01Z"),temp:14,},{_id:5,source:"strawberry",dt:new Date("2019-01-08T06:12:03Z"),temp:1,}]

Query

db.collection.aggregate([{$setWindowFields:{partitionBy:"$source",sortBy:{dt:1},output:{history:{$push:{dt:"$dt",t:"$temp"},window:{range:["unbounded",-1],unit:"day"}}}}}])

Result