@earth-app/collegedb
    Preparing search index...

    Function upsert

    • Inserts a row, or updates the conflicting columns when a unique/primary key already exists (INSERT ... ON CONFLICT ... DO UPDATE).

      Type Parameters

      • T = Record<string, unknown>

        Type of returned rows when RETURNING is used

      Parameters

      • key: string

        Primary key used for shard routing

      • table: string

        Target table name

      • values: ColumnValues

        Column to value map for the row

      • conflictColumns: string | string[]

        Column(s) forming the conflict target

      • options: BuildUpsertOptions = {}

        Upsert modifiers (update subset, returning)

      Returns Promise<QueryResult<T>>

      The write result

      1.2.4

      await upsert('settings:theme', 'settings', { key: 'theme', value: 'dark' }, 'key');