Im wondering if the following is possible in MongoDB.
I have collection of documents that represent changes in some value in time:
{
"day" : ISODate("2018-12-31T23:00:00.000Z"),
"value": [some integer value]
}
There are no 'holes' in the data, I have entries for all days within some period.
Is it possible to query this collection to get only documents that has different value than previous one (when sorting by day asc)? For example, having following documents:
{
"day" : ISODate("2019-04-01T00:00:00.000Z"),
"value": 10
},
{
"day" : ISODate("2019-04-02T00:00:00.000Z"),
"value": 10
},
{
"day" : ISODate("2019-04-03T00:00:00.000Z"),
"value": 15
},
{
"day" : ISODate("2019-04-04T00:00:00.000Z"),
"value": 15
},
{
"day" : ISODate("2019-04-05T00:00:00.000Z"),
"value": 15
},
{
"day" : ISODate("2019-04-06T00:00:00.000Z"),
"value": 10
}
I want to retrieve documents for 2018-04-01, 2018-04-03 and 2018-04-06.
Im posting this question again because previous one was wrongly marked as duplicate.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…