Skip to content

Commit

Permalink
Fix mods with no updates do not appear
Browse files Browse the repository at this point in the history
  • Loading branch information
henkelmax committed Oct 3, 2020
1 parent efc7600 commit cbe4abb
Showing 1 changed file with 30 additions and 14 deletions.
44 changes: 30 additions & 14 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,18 +186,26 @@ const amountSchema = Joi.number()
}
},
{
$unwind: '$updates'
$unwind: {
path: '$updates',
preserveNullAndEmptyArrays: true
}
},
{
$addFields: {
updateCount: {
$arrayElemAt: [
$ifNull: [
{
$map: {
input: { $objectToArray: '$updates' },
as: 'c',
in: '$$c.v'
}
$arrayElemAt: [
{
$map: {
input: { $objectToArray: '$updates' },
as: 'c',
in: '$$c.v'
}
},
0
]
},
0
]
Expand Down Expand Up @@ -245,18 +253,26 @@ const amountSchema = Joi.number()
}
},
{
$unwind: '$updates'
$unwind: {
path: '$updates',
preserveNullAndEmptyArrays: true
}
},
{
$addFields: {
updateCount: {
$arrayElemAt: [
$ifNull: [
{
$map: {
input: { $objectToArray: '$updates' },
as: 'c',
in: '$$c.v'
}
$arrayElemAt: [
{
$map: {
input: { $objectToArray: '$updates' },
as: 'c',
in: '$$c.v'
}
},
0
]
},
0
]
Expand Down

0 comments on commit cbe4abb

Please sign in to comment.