[SERVER-27589] Return single object instead of array in $lookup if useer want Created: 05/Jan/17  Updated: 06/Dec/22  Resolved: 13/Jan/17

Status: Closed
Project: Core Server
Component/s: Aggregation Framework
Affects Version/s: None
Fix Version/s: None

Type: New Feature Priority: Major - P3
Reporter: Shaishab Roy Assignee: Backlog - Query Team (Inactive)
Resolution: Duplicate Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-22384 Add $lookUpOne to retrieve single Obj... Open
Assigned Teams:
Query
Participants:

 Description   

When we use $lookup in aggregate query of MongoDB we use this format

{
   $lookup:
     {
       from: "users",
       localField: "userId",
       foreignField: "_id",
       as: "user"
     }
}

where user return as an array of object and then some time we need to use $arrayElemAt in $project stage to return as a single object. like

{
  $project:
   {
    user:
      { 
        $arrayElemAt: [ "$user", 0 ] 
      }
   }
}

so my request is can create option to return user as a single object instead of array from $lookup stage ?



 Comments   
Comment by David Storch [ 13/Jan/17 ]

Hi shaishab,

This looks like a duplicate of SERVER-22384, so we are closing this ticket. Please watch SERVER-22384 for further updates.

Best,
Dave

Comment by Shaishab Roy [ 05/Jan/17 ]

Thank you for your cordially response @Thomas Schubert

Comment by Kelsey Schubert [ 05/Jan/17 ]

Hi shaishab,

Thanks for the feature request. I've sent this to the Query Team for consideration.

Kind regards,
Thomas

Generated at Thu Feb 08 04:15:35 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.