Questions tagged [mongodb-lookup]
41 questions
0
votes
2 answers
One to Many MongoDB lookup with project req fields
I have a one to many relationship of two Collections say A to B. How can I i show the desired output in one document for each id.
For example, I have
/*Collection A*/
{
"a_Id": "abc",
"name": "xyz",
"age": 5
}
...//Other…

Wajih
- 93
- 1
- 10
0
votes
1 answer
How to apply $lookup in MongoDB, If the record on the second collection is deleted still give the response all the record of the first collection
How to apply $lookup in MongoDB, If the record on the second collection is deleted still give the response all the record of the first collection as shown in the given example
first collection
A: [
{ _id : "a" , P : "dljslfsdjf" },
…

Sajal Mishra
- 13
- 4
0
votes
1 answer
On MongoDb Aggregation lookup, does the let need special formating?
I am trying to use the MongoDB $lookup with the Uncorrelated Subqueries.
Using MongoDB 3.6.12 (support began on 3.6)
https://docs.mongodb.com/manual/reference/operator/aggregation/lookup/#join-conditions-and-uncorrelated-sub-queries
The following…

user2502794
- 127
- 2
- 15
0
votes
1 answer
MongoDB Aggregation pipeline inner array mapping
I am trying to perform a lookup operation between two collections like shown below,
first collection records:
{
field1: "FIELD",
title: "sometitle",
secondIds: [
{
value: "nestedval1",
secondId: "234
},
{
value: "netedval2,
…

Sameesh
- 315
- 8
- 18
0
votes
1 answer
Mongo lookup returning all values
I have 2 collections as shown below:
branches
{
_id: ...,
custId: "abc123",
branchCode: "AA",
...other fields
}
branchHolidays
{
_id: ...,
custId: "abc123",
holidayDate: ISODate("2019-06-01T00:00:00:0000"),
holidayStatus:…

Pi53
- 211
- 1
- 4
- 11
0
votes
0 answers
mongoDB aggregation on large dataset has run for HOURS with no end in sight. Normal? Or can I speed this up?
I have a collection of 6-7 million event records. I have another collection of ~100,000 hourly weather records spanning the same timeframe as the event records. I am using an $aggregate pipeline with $lookup to merge in relevant weather data for…

sahase
- 3
- 2
0
votes
1 answer
Use fields that start with $ in MongoDB aggregation lookup
I have a MongoDB database that is populated by a Spring application using Spring Data. I want to perform a manual query to join two collections and extract some statistics from this data.
The first collection is named emailCampaign and contains this…

redent84
- 18,901
- 4
- 62
- 85
0
votes
1 answer
Nested lookup in mongo db query
I am making a airline dummy webside, and i need get all sold tickets per flight for all airlines, i have 3 collections: airlines, flights and sales
I tried using a nested lookups in mongodb query, but i cant sum the total tickets, here is the…
0
votes
0 answers
$lookup seems to match null as lookup information
I have the following lookup and gives me strange results for documents who do not have an id_bidon. It's like it defaults to null and is matched to the first document who doesn't have a id_client_bidon. Is there a way around this?
{
from: 'book',
…

MusicAndCode
- 870
- 8
- 22
0
votes
0 answers
Mongodb $lookup how to join a field with $id to $id.toString
I have a two collections
Collection1
{
_id: ObjectId("5ba27d02d579d8cd47a02408"),
NAME: "xxxx",
DESC: "xxxxxx"
}
Collection2
{
_id: ObjectId("5ba2900dd579d8cd47a026b7")
COLLECTION1_ID: "5ba27d02d579d8cd47a02408"
ORDER:…

Shashank
- 247
- 5
- 17
0
votes
1 answer
Mongodb - $group with $addToSet and then $lookup
I've got the following query
db.getCollection('transportations').aggregate(
{
$group: {
_id: null,
departure_city_id: { $addToSet: "$departure.city_id" },
departure_station_id: { $addToSet: "$departure.station_id" }
…

Michalis
- 6,686
- 13
- 52
- 78