Instance Subscriptgrdb 7.1.0GRDB
subscript(_:)
Returns an SQL ordering term that refers to the aliased table.
subscript(ordering: some SQLOrderingTerm) -> SQLOrdering { get }
For example, let’s sort books by author name first, and then by title:
// SELECT book.*
// FROM book
// JOIN author ON author.id = book.authorId
// ORDER BY author.name ASC, book.title ASC
let authorAlias = TableAlias()
let request = Book
.joining(required: Book.author.aliased(authorAlias))
.order(authorAlias[Column("name").asc], Column("title").asc)