My MongoDB trasanction collection has data represented like this:
[{'_id': ObjectId('6080d0a3bea947d567d9afba'), '_cls': 'BaseModel.LoyaltyCardScanModel', 'uuid': UUID('af35fe28-a309-11eb-bc8e-2ad4b4403f63'), 'place_uuid': UUID('483c8bb0-9e95-11eb-821a-42f2f9ada1ca'), 'user_uuid': UUID('35f831f8-a308-11eb-a237-2ad4b4403f63'), 'admin_uuid': UUID('8a022d9b-96e1-11eb-a58d-bc5ff48c075c'), 'user': ObjectId('6080ce2ad8c7ca00ececa252'), 'place':ObjectId('6079575cec0b3b2d62dbbcce'), 'scan_dates': ['2021-04-22 01:25:55.445332', '2021-04-22 01:29:37.231813'], 'last_scan_date': datetime.datetime(2021, 4, 22, 1, 29, 37, 231000), 'expiration_date': datetime.datetime(2021, 5, 22, 1, 29, 37, 231000), 'scans_count': 2, 'created_at': datetime.datetime(2021, 4, 22, 1, 25, 55, 451000), 'updated_at': datetime.datetime(2021, 4, 22, 1, 29, 37, 242000)}]
My goal is to get transaction documents from places that contain a string in their name.
I have tried the following aggregation pipeline and it worked:
[
{"$lookup": {
"from": "place_model",
"let": {"uuid": "$place_uuid"},
"pipeline": [
{"$match": {"name": "/whateverstring/"}},
{"$match": {"$expr": {"$eq": ["$uuid", "$uuid"]}}},
{"$project": {"uuid": 1, "name": 1}}
],
"as": "place"
}},
{
'$skip': 10
}, {
'$limit': 1
}
]
But I also want get the user data from its ObjectID, but the users document are in another database. How can I do that?