I have a table in db. and when i use this code
results = db().select(db.project.ALL, orderby=db.project.id, groupby=db.project.status)
I can only choose the last row in repeats. how could i choose the first one?
The select()
method will return a Rows
object, which is a itterable collection of Row
objects. The order of which rows will apear in your results
variable will vary depending on your orderby
parameter passed to your select()
method. If you simply want to get a single record, which is the first one out of your select()
, you could change the above code to:
results = db().select(db.project.ALL, orderby=db.project.id, groupby=db.project.status).first()
But if your intent is to reverse the order of which you're getting the rows in result, add the tilde operator (~
) to your orderby
parameter, which will result in adding a ORDER BY ____ DESC
in relational databases. Eg:
results = db().select(db.project.ALL, orderby=~db.project.id, groupby=db.project.status)