I am a developer living in Korea. Please understand my poor English.
How would I convert the following MongoDB query into a query to be used by my Java Spring application? I can't find a way to use pipeline with the provided lookup method.
I've tried this method, but it's no use.
Spring Data MongoDB Lookup with Pipeline Aggregation
db.component_class.aggregate(
[
{
$match: {superior_id: '5d64ab6e2a41be4f74cf12d7'}
},
{
$lookup: {
from:'component',
let: {cc_id: '$_id'},
pipeline: [
{'$addFields': {'component_class_id': {'$toObjectId': '$component_class_id'}}},
{'$match': {'$expr': {'$eq': ['$component_class_id', '$$cc_id']}}},
{
'$lookup': {
from: 'sensor',
let: {c_id: '$_id'},
pipeline: [
{'$addFields': {'component_id': {'$toObjectId': '$component_id'}}},
{'$match': {'$expr': {'$eq': ['$component_id', '$$c_id']}}}
],
as: 'sensor_docs'
}
}
],
as: 'component_docs'
}
}
]
)