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

$project in $lookup mongodb

Sie können $lookup verwenden 3.6-Syntax in $project die Felder in $lookup Leitung

User.aggregate([
  { "$lookup": {
    "from": "schedules",
    "let": { "id": "$_id.phone" },
    "pipeline": [
      { "$match": { "$expr": { "$eq": ["$customer.phone", "$$id"] }}},
      { "$project": { "scheduleStart": 1, "scheduleEnd": 1 }}
    ],
    "as": "user_detail"
  }}
])