[CommonExtraData(count=7), CommonExtraData(count=2)][CommonExtraData(count=5), CommonExtraData(count=1)]Say I have an ndb.Model class that I want to use as a StructuredProperty on another model class:class CommonExtraData(ndb.Model): count = ndb.IntegerProperty(required=True)class MyObject(ndb.Model): name = ndb.StringProperty(required=True) extra = ndb.StructuredProperty(CommonExtraData, required=True)Could I then do a query like this:MyObject.query().order(-MyObject.extra.count)I can't find an example in the docs, and my dev environment is not currently working due to my endeavors of refactoring from the old API to NDB. 解决方案 Just did a bit of experimentation and it appears to be working. You should be able to do it exact as you wrote out.In experimenting, I found one quirk that should be noted - if you use repeated property, it appears to sort on the first instance of the repeated property only. For example, if your repeated property had [CommonExtraData(count=5), CommonExtraData(count=1)] and another had [CommonExtraData(count=7), CommonExtraData(count=2)], it would sort like this:[CommonExtraData(count=7), CommonExtraData(count=2)][CommonExtraData(count=5), CommonExtraData(count=1)] 这篇关于NDB 按 StructuredProperty 的属性排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-21 14:53