MongoDB
 sql >> Datenbank >  >> NoSQL >> MongoDB

Mongodb-Aggregatargumente für $lookup müssen Zeichenfolgen sein

Weil Sie versuchen, $lookup zu verwenden Funktionen (Syntax) von MongoDB v3.6 auf MongoDB v3.4

MongoDB v3.4 $lookup Syntax:

{
   $lookup:
     {
       from: <collection to join>,
       localField: <field from the input documents>,
       foreignField: <field from the documents of the "from" collection>,
       as: <output array field>
     }
}

Die MongoDB v3.6 $lookup Syntax:

{
   $lookup:
     {
       from: <collection to join>,
       let: { <var_1>: <expression>, …, <var_n>: <expression> },
       pipeline: [ <pipeline to execute on the collection to join> ],
       as: <output array field>
     }
}

https://docs.mongodb.com/manual/reference/operator/ Aggregation/Suche/