db

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 30, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

README

db

Raw psql queries.

Create migration

 migrate create -ext sql -dir _migrations/ -seq name

Configuring local psql

To configure PostgreSQL for local authentication with a username and password on Ubuntu:

Set a password for the PostgreSQL user:

sudo -u postgres psql
\password postgres

Enter the desired password.

Edit pg_hba.conf to use password authentication:

Open the file (location: /etc/postgresql//main/pg_hba.conf).

Change local and/or host lines for your user/database to use md5 or scram-sha-256:

local   all   postgres   md5
host    all   postgres   127.0.0.1/32   md5

Save and exit.

Reload PostgreSQL:

sudo systemctl reload postgresql

Now you can connect using:

psql -U postgres -h localhost -W

You'll be prompted for the password.

Migrating local database

go run ./cmd/example migrate

Documentation

Overview

Package entdb provides helper for creating pgx dabase for ent.

Index

Constants

This section is empty.

Variables

View Source
var Migrations embed.FS

Functions

func Open

func Open(ctx context.Context, uri string, t *app.Telemetry) (*pgxpool.Pool, error)

Open new connection.

Types

type DB

type DB struct {
	// contains filtered or unexported fields
}

func New

func New(pgx *pgxpool.Pool) *DB

func (DB) CreateTask added in v0.3.0

func (db DB) CreateTask(ctx context.Context, title string) (*example.Task, error)

func (DB) DeleteTask added in v0.3.0

func (db DB) DeleteTask(ctx context.Context, id int64) error

func (DB) GenerateError added in v0.3.0

func (db DB) GenerateError(ctx context.Context) error

func (DB) ListTasks added in v0.3.0

func (db DB) ListTasks(ctx context.Context) ([]*example.Task, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL