Skip to content

Commit 9f39683

Browse files
committed
Add order method to query that takes an array arg
1 parent ad4b7a9 commit 9f39683

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Source/Typed/Query.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,22 @@ extension QueryType {
399399
///
400400
/// - Returns: A query with the given `ORDER BY` clause applied.
401401
public func order(by: Expressible...) -> Self {
402+
return order(by)
403+
}
404+
405+
/// Sets an `ORDER BY` clause on the query.
406+
///
407+
/// let users = Table("users")
408+
/// let email = Expression<String>("email")
409+
/// let name = Expression<String?>("name")
410+
///
411+
/// users.order([email.desc, name.asc])
412+
/// // SELECT * FROM "users" ORDER BY "email" DESC, "name" ASC
413+
///
414+
/// - Parameter by: An ordered list of columns and directions to sort by.
415+
///
416+
/// - Returns: A query with the given `ORDER BY` clause applied.
417+
public func order(by: [Expressible]) -> Self {
402418
var query = self
403419
query.clauses.order = by
404420
return query

0 commit comments

Comments
 (0)