Introduce DatabaseCursor (addresses #147)

let cursor = try Row.fetchCursor(db, "SELECT * FROM persons)
while let row = try cursor.step() { ... }
This commit is contained in:
Gwendal Roué committed 2016-11-25 18:34:16 +01:00
1 parent adc4ae48d6
commit b9fea2ea12
8 files changed
+222 -44

No files matched your search

@@ -30,6 +30,11 @@ extension QueryInterfaceRequest where T: RowConvertible {
// MARK: Fetching Record and RowConvertible
/// TODO
public func fetchCursor(_ db: Database) throws -> DatabaseCursor<T> {
return try T.fetchCursor(db, self)
}
/// A sequence of fetched records.
///
/// let nameColumn = Column("name")
@@ -483,6 +488,11 @@ extension RowConvertible where Self: TableMapping {
// MARK: Fetching All
/// TODO
public static func fetchCursor(_ db: Database) throws -> DatabaseCursor<Self> {
return try all().fetchCursor(db)
}
/// A sequence of all records fetched from the database.
///
/// let persons = Person.fetch(db) // DatabaseSequence<Person>