Skip to content

Commit b79a9e2

Browse files
committed
Document SwiftSQLExt APIs
1 parent 6523edb commit b79a9e2

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,16 @@ try db.prepare("INSERT INTO Users (Name) VALUES (?)")
107107
Add conformance to `SQLRowDecodable` to use convenience APIs for converting rows into your model entities.
108108

109109
```swift
110-
110+
// Fetch all of the rows
111+
let users = try db
112+
.prepare("SELECT Name, Level FROM Users ORDER BY Level ASC")
113+
.rows(User.self)
114+
115+
// Or only the next row
116+
statement.row(User.self)
117+
118+
// Or the next N rows
119+
statement.rows(User.self, count: 50)
111120
```
112121

113122
# Minimum Requirements

Sources/SwiftSQLExt/SwiftSQLExt.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public extension SQLStatement {
1717

1818
/// Fetches the first `count` rows returned by the statement. By default,
1919
/// fetches all rows.
20-
func rows<T: SQLRowDecodable>(count: Int? = nil, _ type: T.Type) throws -> [T] {
20+
func rows<T: SQLRowDecodable>(_ type: T.Type, count: Int? = nil) throws -> [T] {
2121
var objects = [T]()
2222
let limit = count ?? Int.max
2323
while let object = try row(T.self), objects.count < limit {

0 commit comments

Comments
 (0)