Static Methodgrdb 7.4.0GRDB

selectID

Returns a request that selects the primary key.

TableRecord+QueryInterfaceRequest.swift:278
static func selectID() -> QueryInterfaceRequest<Self.ID> where Self : Identifiable

For example:

// SELECT id FROM player
let request = try Player.selectID()

Important: if the record type has an ID type that is an optional, such as Int64?, it is recommended to prefer selectPrimaryKey(as:) instead:

struct Player: Identifiable {
    var id: Int64?
}

// NOT RECOMMENDED: Set<Int64?>
let ids = try Player.selectID().fetchSet(db)

// BETTER: Set<Int64>
let ids = try Player.selectPrimaryKey(as: Int64.self).fetchSet(db)