Образец моей коллекции:
[
{
_id: "bmasndvhjbcw",
name: "lucas",
occupation: "scientist",
age: 55,
location: "texas",
joining_date: 2019-01-01T15:24:15.068+00:00
},
{
_id: "bmasndvhjbcx",
name: "mark",
occupation: "scientist",
age: 45,
location: "texas",
joining_date: 2019-01-01T15:24:15.068+00:00
},
{
_id: "bmasndvhjbca",
name: "stuart",
occupation: "lab assistant",
age: 25,
location: "texas",
joining_date: 2019-01-02T20:25:16.068+00:00
},
{
_id: "bmasndvhjbcq",
name: "cooper",
occupation: "physicist",
age: 69,
location: "texas"
}
]
В каких документах есть столбец joining_date , необходимо добавить поле с возрастающим значением, проверив дату как joining_date_count:1
если даты совпадают, как в двух случаях mark
и lucas
. count должен рассматривать его как разные значения и увеличивать счет.
Ожидаемый результат:
[
{
_id: "bmasndvhjbcw",
name: "lucas",
occupation: "scientist",
age: 55,
location: "texas",
joining_date: 2019-01-01T15:24:15.068+00:00,
joining_date_count:1
},
{
_id: "bmasndvhjbcx",
name: "mark",
occupation: "scientist",
age: 45,
location: "texas",
joining_date: 2019-01-01T15:24:15.068+00:00,
joining_date_count:2
},
{
_id: "bmasndvhjbca",
name: "stuart",
occupation: "lab assistant",
age: 25,
location: "texas",
joining_date: 2019-01-02T20:25:16.068+00:00,
joining_date_count:3
},
{
_id: "bmasndvhjbcq",
name: "cooper",
occupation: "physicist",
age: 69,
location: "texas"
}
]