Lookup "as" field doest work with array path

Hello Mongo Comunity,

Basically I want to lookup a collection inside another collection.

The destination of the “from” collection is an array with objects that match foreign/local field.

I can place the lookup result in the root of the collection, but when i try put the destination array path it doesnt work.

The array shows as empty object (all fields that should be there are gone) only with the “from” collection inside.

Am I doing it wrong?

Thank you

Hello @Vasco_Pedro, welcome to the MongoDB Community forum :slight_smile:

Please include an example document and the aggregation query you are working with, so as to get a better idea what you are trying. It is little difficult to visualize what you are trying.

1 Like

Welcome to the MongoDB community forums @Vasco_Pedro!

In addition to @Prasad_Saya’s suggestions, it would be helpful to confirm the MongoDB server version you are using (for example, via the output of db.version() in the mongo shell).

There have been improvements to aggregation features in successive major releases of MongoDB, so there may be more efficient ways to achieve your desired outcome depending on your MongoDB server version.

Thanks,
Stennie

1 Like

Thank you I found a workaround