Instance Methodgrdb 7.3.0GRDB

primaryKey(onConflict:autoincrement:)

Adds a primary key constraint.

ColumnDefinition.swift:135
@discardableResult func primaryKey(onConflict conflictResolution: Database.ConflictResolution? = nil, autoincrement: Bool = false) -> Self

Parameters

conflictResolution

An optional ConflictResolution.

autoincrement

If true, the primary key is autoincremented.

Returns

self so that you can further refine the column definition.

For example:

// CREATE TABLE player(
//   id TEXT NOT NULL PRIMARY KEY
// )
try db.create(table: "player") { t in
    t.primaryKey("id", .text)
}