GitHubComeçar

A referência da API é gerada a partir dos comentários de documentação Go no código-fonte e está escrita em inglês.

package pgstore

import "github.com/nsgo-dev/game/pkg/accounts/pgstore"

Visão geral

Package pgstore opens an accounts.Store in a Postgres database with the github.com/jackc/pgx/v5 driver. Several account service processes may share one database: its constraints keep email addresses and identities unique, and migrations take an advisory lock.

Índice

Variáveis

var Dialect = sqlstore.Dialect{
	Name:     "postgres",
	Numbered: true,
	IsUnique: func(err error) bool {
		var e *pgconn.PgError
		return errors.As(err, &e) && e.Code == uniqueViolation
	},

	MigrateLock: `SELECT pg_advisory_xact_lock(1633903476)`,
}

Dialect is Postgres's sqlstore dialect.

Funções

func New(ctx context.Context, db *sql.DB) (*sqlstore.Store, error)

New returns a store on an open Postgres database, creating the schema when it is missing.

func Open(ctx context.Context, dsn string) (*sqlstore.Store, error)

Open connects to the Postgres database dsn names (a URL or a key=value string, as pgx parses it) and returns a store on it with the schema created. Keep the DSN, which may hold a password, out of logs and command lines: read it from the environment or a file. Close the store to close the connections.