Hello . I have this kind of data ( dates an values )
I know how to select and return them but how to delete my selection in an aggregation /$project like this ??? no solution anywhere thanks a lot for your help
/**
[
{ date: '2021-05-12T03:00:00+02:00', v: 19.81 },
{ date: '2021-05-12T04:00:00+02:00', v: 19.59 },
{ date: '2021-05-12T05:00:00+02:00', v: 19.31 },
{ date: '2021-05-12T06:00:00+02:00', v: 19.14 },
{ date: '2021-05-12T07:00:00+02:00', v: 18.02 },
{ date: '2021-05-12T08:00:00+02:00', v: 20.81 },
{ date: '2021-05-12T09:00:00+02:00', v: 24.91 },
{ date: '2021-05-12T10:00:00+02:00', v: 26.62 },
...
*/
collection.aggregate([
{ $match: {_id: ObjectID("xxxxxxxxxxxxxxxxxxx")}},
{
$project: {
[`mydataArray`]: {
$filter: {
input: `$mydataArray`, // array i filterering
as : "item",
cond : {
$and:
[
{ $gte :["$$item.date", moment(from).format() ] },
{ $lte :["$$item.date", moment(to).format() ] }
]
}
}
}
}
}
]) // then how to delete ?????