[sqlite] How to order by rowid?

Having a query like:
db.query.countryTable.findAll({
where: eq(countryTable.continentId, continentId),
orderBy: // how to order by rowid
})
db.query.countryTable.findAll({
where: eq(countryTable.continentId, continentId),
orderBy: // how to order by rowid
})
I would like to order by the sqlite rowid. Maybe in this example it would make more sense to order by the country name, but this just for an example. In my case I have no natural column to order by, but want to sort on rowid.
2 Replies
⚡Z.E.U.S⚡
⚡Z.E.U.S⚡3mo ago
@Marcel Overdijk Hey! Try:
db.query.countryTable.findAll({
where: eq(countryTable.continentId, continentId),
orderBy: asc(sql`rowid`)
})
db.query.countryTable.findAll({
where: eq(countryTable.continentId, continentId),
orderBy: asc(sql`rowid`)
})
Marcel Overdijk
Marcel OverdijkOP3mo ago
thx a lot @⚡Z.E.U.S⚡ I will try this later when at home. I can confirm this worked, thx again @⚡Z.E.U.S⚡ !
Want results from more Discord servers?
Add your server