mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-29 04:24:21 +00:00
Since Optional is a database value like others, selectID would be a request of optionals for records with an optional ID type:
struct Player: Identifiable, MutablePersistableRecord {
var id: Int64?
}
Player.selectID() // QueryInterface<Int64?>
This is not good, because primary keys are not null. And those requests would fetch impractical types such as [Int64?], Set<Int64?>, Int64??.
Instead, we introduce selectPrimaryKey(as:), which allows the user to provide the desired type.
Player.selectPrimaryKey(as: Int64.self) // QueryInterface<Int64>
Demo Applications
- GRDBDemoiOS: a storyboard-based UIKit application.
- GRDBCombineDemo: a Combine + SwiftUI application.
- GRDBAsyncDemo: a Async/Await + SwiftUI application.
GRDBCombineDemo and GRDBAsyncDemo use the same @Query property wrapper, that lets SwiftUI views automatically update their content when the database changes. It is defined in the GRDBQuery package.