Static Methodgrdb 7.3.0GRDB

fetchCount(_:)

Returns the number of records in the database table.

TableRecord.swift:253
static func fetchCount(_ db: Database) throws -> Int

Parameters

db

A database connection.

For example:

struct Player: TableRecord { }

try dbQueue.read { db in
    // SELECT COUNT(*) FROM player
    let count = try Player.fetchCount(db)
}