Hello again! > How should one execute "group by" or "order by" in the Storm ORM way?
GROUP BY is already designed, but isn't yet implemented. It will probably be the next feature implemented. Here's how it will work: foo, count = store.find((Foo, Count(Foo.name))).group_by(Foo.name) I've added another section to the tutorial about ordering and limiting of results. Here it is: ==== Ordering and limiting results ==== Ordering and limiting results obtained are certainly among the simplest and yet most wanted features for such tools, so we want to make them very easy to understand and use, of course. A code of line is worth a thousand words, so here are a few examples that demonstrate how it works: >>> garry = store.add(Employee(u"Garry Glare")) >>> result = store.find(Employee) >>> [employee.name for employee in result.order_by(Employee.name)] [u'Ben Bill', u'Garry Glare', u'Mike Mayer'] >>> [employee.name for employee in result.order_by(Desc(Employee.name))] [u'Mike Mayer', u'Garry Glare', u'Ben Bill'] >>> [employee.name for employee in result.order_by(Employee.name)[:2]] [u'Ben Bill', u'Garry Glare'] -- Gustavo Niemeyer http://niemeyer.net -- storm mailing list [email protected] Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/storm
