MongoDB
 sql >> Database >  >> NoSQL >> MongoDB

$progetto in $lookup mongodb

Puoi utilizzare $lookup 3.6 sintassi per $project i campi all'interno di $lookup pipeline

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