mongoengine
mongoengine copied to clipboard
It would be nice if the QuerySet functions only, exclude, order_by and such could take Fields
I find myself constantly writing code like:
directories = Directory.objects(parent=directory.id)
directories.only(Directory.path.db_field)
directories.order_by(Directory.path.db_field)
What would be nice is something without having to reference db_field.
directories.only(Directory.path)
directories.order_by([(Directory.path, ASCENDING)])
I have been working on the exact same thing for the Django ORM. I don't think we will see it implemented for MongoEngine at the time being since it's extremely complex.
Yeah, there could be a way to pass a list or tuple to order_by() function instead of comma separated keyword arguments :)
Closing this as the issue is quite old and didn't receive much upvotes