heynemann / motorengine

Motorengine is a port of MongoEngine for Tornado.
http://motorengine.readthedocs.org
204 stars 67 forks source link

Ordering by id #101

Closed lordent closed 5 years ago

lordent commented 8 years ago

Hi, i try to sorting queryset and get this error:

File "/env/lib/python3.4/site-packages/motorengine/queryset.py", line 443, in order_by raise ValueError("Invalid order by field '%s': Field not found in '%s'." % (field_name, self.klass.name)) ValueError: Invalid order by field '_id': Field not found in 'Model'

heynemann commented 8 years ago

Hmmm... I don't think we support sorting by a field you didn't define. Since _id is an autogenerated field, you won't be able to sort by it. Sorry. :(

lordent commented 8 years ago

@heynemann I think, that _id is same fileds as ather, for example, if u created two records like {name: 'A'} and {name: 'B'}, then default sorting to be _id, right?