Its posible add $cond into $connectToField example
{ $graphLookup: { from: 'samecollection', startWith: '$myid', connectFromField: 'myid', connectToField: { $cond: { true , 'myidsRelated.id', 'newRelated.id'} }, as: 'elements', }, },
Its posible add $cond into $connectToField example
{ $graphLookup: { from: 'samecollection', startWith: '$myid', connectFromField: 'myid', connectToField: { $cond: { true , 'myidsRelated.id', 'newRelated.id'} }, as: 'elements', }, },
Copyright © 2021 Jogjafile Inc.
No, it is not possible. The
connectToFieldparameter only allows you to specify the name of the field to join to. It does not support expressions (and this is the reason why the field name is specified without the$prefix).However, there is a
restrictSearchWithMatchoption that you can use to filter the documents you want to participate in the lookup. For example: