1

my query is ...

aggregate[{
        $lookup: {
            "from": "replacement_articles",
            "localField": "_id",
            "foreignField": "userid",
            "as": "replacement_articles"
        }
    },
        {
            $unwind: "$replacement_articles"
        },
        {
            _id: "$id",
            article_count: { "$push": { "$size": "replacement_articles" } }
        }
    ]

MongoError: The argument to $size must be an array, but was of type:missing

Naresh P
  • 21
  • 5
  • 1
    please understand the question clearly.... my question is ... How to count the number of instances in foreign collection – Naresh P May 10 '18 at 05:50
  • I am facing the same problem and I think this is not a duplicate question. `$size` somehow doesn't work properly if I am trying to get size of an array inside a foreign collection! – planet_hunter Aug 09 '18 at 15:59

0 Answers0