postgres

package
v0.0.0-...-7b55a8f Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Copyright (c) 2024 rodneyosodo

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at: http://www.apache.org/licenses/LICENSE-2.0

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at: http://www.apache.org/licenses/LICENSE-2.0

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at: http://www.apache.org/licenses/LICENSE-2.0

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connect

func Connect(cfg Config) (*sqlx.DB, error)

func Setup

func Setup(cfg Config, migrations migrate.MemoryMigrationSource) (*sqlx.DB, error)

func Total

func Total(ctx context.Context, db Database, query string, params interface{}) (uint64, error)

Types

type Config

type Config struct {
	Host        string `env:"HOST"          envDefault:"localhost"`
	Port        string `env:"PORT"          envDefault:"5432"`
	User        string `env:"USER"          envDefault:"twiga"`
	Pass        string `env:"PASS"          envDefault:"twiga"`
	Name        string `env:"NAME"          envDefault:""`
	SSLMode     string `env:"SSL_MODE"      envDefault:"disable"`
	SSLCert     string `env:"SSL_CERT"      envDefault:""`
	SSLKey      string `env:"SSL_KEY"       envDefault:""`
	SSLRootCert string `env:"SSL_ROOT_CERT" envDefault:""`
}

type Database

type Database interface {
	NamedQueryContext(ctx context.Context, query string, args interface{}) (*sqlx.Rows, error)
	NamedExecContext(ctx context.Context, query string, args interface{}) (sql.Result, error)
	QueryRowxContext(ctx context.Context, query string, args ...interface{}) *sqlx.Row
	QueryxContext(ctx context.Context, query string, args ...interface{}) (*sqlx.Rows, error)
	QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
	ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
	BeginTxx(ctx context.Context, opts *sql.TxOptions) (*sqlx.Tx, error)
}

Database provides a database interface.

func NewDatabase

func NewDatabase(db *sqlx.DB, config Config, tracer trace.Tracer) Database

NewDatabase creates a Clients'Database instance.

Jump to

Keyboard shortcuts

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