Static Methodgrdb 7.4.0GRDB

fetchCursor(_:keys:)

Returns a cursor over records identified by their primary keys.

FetchableRecord+TableRecord.swift:131
static func fetchCursor(_ db: Database, keys: some Collection<some DatabaseValueConvertible>) throws -> RecordCursor<Self>

Parameters

db

A database connection.

keys

A sequence of primary keys.

Returns

A RecordCursor over fetched records.

Throws

A DatabaseError whenever an SQLite error occurs.

For example:

try dbQueue.read { db in
    let players = try Player.fetchCursor(db, keys: [1, 2, 3])
    while let player = try players.next() {
        print(player.name)
    }
}

The order in which the records are returned is undefined (ref).

The returned cursor is valid only during the remaining execution of the database access. Do not store or return the cursor for later use.

If the database is modified during the cursor iteration, the remaining elements are undefined.