Tweak single MongoDB query so aggregate > lookup doesn't return all fields in lookup collection

Closed Posted 5 years ago Paid on delivery
Closed Paid on delivery

I have a MongoDB query:

var queryLookup = {from:'fromCollection',localField:'field',foreignField:'otherField',as:'lookup_info'}

[login to view URL]({$match:queryObj},{$lookup:queryLookup},{$project:queryProject},{$sort:sortObj}).toArray(function(err,items){});

However, the lookup_info value is an array with the first element being the entire set of data fields from the 'fromCollection'. So 'lookup_info' looks like this:

lookup_info: [{'field1':'val','field2':'val','field3':'val','field4':'val'}]

and instead I want this (notice, no array):

lookup_info: {'field1':'val','field4':'val'}

MongoDB

Project ID: #18245497

About the project

1 proposal Remote project Active 5 years ago

1 freelancer is bidding on average $50 for this job

freelancernewtec

Hello, I would like to take this assignment. I am having 14 years of experience on web development, deployment and project management. Below are my core technical skills •ASP.Net /HTML/CSS/JavaScript/JQuery •C# More

$50 USD in 1 day
(0 Reviews)
0.0