mongoengine icon indicating copy to clipboard operation
mongoengine copied to clipboard

It would be nice if the QuerySet functions only, exclude, order_by and such could take Fields

Open rminsk opened this issue 12 years ago • 3 comments

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)])

rminsk avatar Jul 15 '14 21:07 rminsk

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.

thedrow avatar Jul 26 '14 10:07 thedrow

Yeah, there could be a way to pass a list or tuple to order_by() function instead of comma separated keyword arguments :)

hamzawaqas-10p avatar Jun 16 '15 06:06 hamzawaqas-10p

Closing this as the issue is quite old and didn't receive much upvotes

bagerard avatar Oct 31 '19 19:10 bagerard