diff --git a/Sources/FluentKit/Query/Builder/QueryBuilder+Range.swift b/Sources/FluentKit/Query/Builder/QueryBuilder+Range.swift index aa5b3505..516c26a5 100644 --- a/Sources/FluentKit/Query/Builder/QueryBuilder+Range.swift +++ b/Sources/FluentKit/Query/Builder/QueryBuilder+Range.swift @@ -6,6 +6,7 @@ extension QueryBuilder { /// query.range(2..<5) // returns at most 3 results, offset by 2 /// /// - returns: Query builder for chaining. + @discardableResult public func range(_ range: Range) -> Self { return self.range(lower: range.lowerBound, upper: range.upperBound - 1) } @@ -15,6 +16,7 @@ extension QueryBuilder { /// query.range(...5) // returns at most 6 results /// /// - returns: Query builder for chaining. + @discardableResult public func range(_ range: PartialRangeThrough) -> Self { return self.range(upper: range.upperBound) } @@ -24,6 +26,7 @@ extension QueryBuilder { /// query.range(..<5) // returns at most 5 results /// /// - returns: Query builder for chaining. + @discardableResult public func range(_ range: PartialRangeUpTo) -> Self { return self.range(upper: range.upperBound - 1) } @@ -33,6 +36,7 @@ extension QueryBuilder { /// query.range(5...) // offsets the result by 5 /// /// - returns: Query builder for chaining. + @discardableResult public func range(_ range: PartialRangeFrom) -> Self { return self.range(lower: range.lowerBound) } @@ -42,6 +46,7 @@ extension QueryBuilder { /// query.range(2..<5) // returns at most 3 results, offset by 2 /// /// - returns: Query builder for chaining. + @discardableResult public func range(_ range: ClosedRange) -> Self { return self.range(lower: range.lowerBound, upper: range.upperBound) } @@ -52,6 +57,7 @@ extension QueryBuilder { /// - lower: Amount to offset the query by. /// - upper: `upper` - `lower` = maximum results. /// - returns: Query builder for chaining. + @discardableResult public func range(lower: Int = 0, upper: Int? = nil) -> Self { self.query.offsets.append(.count(lower)) upper.flatMap { upper in diff --git a/Sources/FluentKit/Query/Builder/QueryBuilder+Sort.swift b/Sources/FluentKit/Query/Builder/QueryBuilder+Sort.swift index 609d8527..e18d863b 100644 --- a/Sources/FluentKit/Query/Builder/QueryBuilder+Sort.swift +++ b/Sources/FluentKit/Query/Builder/QueryBuilder+Sort.swift @@ -1,6 +1,7 @@ extension QueryBuilder { // MARK: Sort + @discardableResult public func sort( _ field: KeyPath, _ direction: DatabaseQuery.Sort.Direction = .ascending @@ -12,6 +13,7 @@ extension QueryBuilder { self.sort(Model.path(for: field), direction) } + @discardableResult public func sort( _ field: KeyPath>, _ direction: DatabaseQuery.Sort.Direction = .ascending @@ -21,6 +23,7 @@ extension QueryBuilder { self.sort(Model.path(for: field), direction) } + @discardableResult public func sort( _ path: FieldKey, _ direction: DatabaseQuery.Sort.Direction = .ascending @@ -28,6 +31,7 @@ extension QueryBuilder { self.sort([path], direction) } + @discardableResult public func sort( _ path: [FieldKey], _ direction: DatabaseQuery.Sort.Direction = .ascending @@ -35,6 +39,7 @@ extension QueryBuilder { self.sort(.extendedPath(path, schema: Model.schemaOrAlias, space: Model.spaceIfNotAliased), direction) } + @discardableResult public func sort( _ joined: Joined.Type, _ field: KeyPath, @@ -49,6 +54,7 @@ extension QueryBuilder { self.sort(Joined.self, Joined.path(for: field), direction, alias: alias) } + @discardableResult public func sort( _ model: Joined.Type, _ path: FieldKey, @@ -60,6 +66,7 @@ extension QueryBuilder { self.sort(Joined.self, [path], direction) } + @discardableResult public func sort( _ model: Joined.Type, _ path: [FieldKey], @@ -71,6 +78,7 @@ extension QueryBuilder { self.sort(.extendedPath(path, schema: Joined.schemaOrAlias, space: Joined.spaceIfNotAliased), direction) } + @discardableResult public func sort( _ field: DatabaseQuery.Field, _ direction: DatabaseQuery.Sort.Direction @@ -79,6 +87,7 @@ extension QueryBuilder { return self } + @discardableResult public func sort(_ sort: DatabaseQuery.Sort) -> Self { self.query.sorts.append(sort) return self