i have a document like this:
{
_id: 1
a: a
b: b
c: [
1, 2, 3, 4, -4, -5, 6, 6
]
}
now i want to use aggregate to make a new field "d: and in that field it will be an array of objects which will show all repeating values and how many they were repeat and if the value is negative like this should be result document.
{
_id: 1
a: a
b: b
c: [
1, 2, 3, 4, -4, -5, 6, 6
]
d: [{value: 1, timeShown: 1 , type: positive}, {value: 2, timeShown: 1, type: positive}, {value: 3, timeShown: 1, type: positive}, {value: 4, timeShown: 1, type: positive}, {value: -4, timeShown: 1, type: negative}, {value: -5, timeShown: 1, type: negative}, {value: 6, timeShown: 2, type: postive}]
}
Without using unwind, sort
because i have used sort too many times already i think it will take more RAM.