Derefence objects efficiently

31 views
Skip to first unread message

Mehdi Khlifi

unread,
Jun 17, 2021, 4:12:02 AM6/17/21
to MongoEngine Developers
Hello,
I have some documents represented like this:
class ScanModel(Document):
uuid = UUIDField(default=uuid1, required=True)
user = LazyReferenceField(UserModel)
restaurant = LazyReferenceField(RestaurantModel)

The restaurant document are in the database as the scan, but the user are in another database. I can query the database to get the restaurant object using aggregation, but I need to fetch() the user object for every document returned because MongoDB doesn't support cross-database $lookup.
Is there a better way to do this? and maybe not have to face the N+1 problem?
Reply all
Reply to author
Forward
0 new messages