U
U
Urukhayy2018-04-24 18:08:31
MongoDB
Urukhayy, 2018-04-24 18:08:31

Why doesn't mongo produce $unwind of arrays on an array?

Document example:

{
myArray: [
    {
        nestedArray: ["a", "b", "c"]
    }
]
}

I make a request like this:
db.collection.aggregate([$unwind: "$myArray.nestedArray"]) // выдаёт пустой ответ
db.collection.aggregate([$unwind: "$myArray"]) // выдаёт нормально

It is required to make $unwind on a nested array, and on an external one. So that the number of rows is myArray.length * nestedArray.length

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Salafan Packages, 2018-05-16
@Urukhayy

Try twice to make $unwind. First "$myArray", second $myArray.nestedArray"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question