dao

package
v0.0.0-...-5a4dc71 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package dao contains generated code for schema 'public'.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Errorf

func Errorf(s string, v ...interface{})

Errorf logs an error message using the package error logger.

func Logf

func Logf(s string, v ...interface{})

Logf logs a message using the package logger.

func SetErrorLogger

func SetErrorLogger(logger interface{})

SetErrorLogger sets the package error logger. Valid logger types:

io.Writer
func(string, ...interface{}) (int, error) // fmt.Printf
func(string, ...interface{}) // log.Printf

func SetLogger

func SetLogger(logger interface{})

SetLogger sets the package logger. Valid logger types:

io.Writer
func(string, ...interface{}) (int, error) // fmt.Printf
func(string, ...interface{}) // log.Printf

Types

type DB

type DB interface {
	ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
	QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
	QueryRowContext(context.Context, string, ...interface{}) *sql.Row
}

DB is the common interface for database operations that can be used with types from schema 'public'.

This works with both database/sql.DB and database/sql.Tx.

type ErrDecodeFailed

type ErrDecodeFailed struct {
	Err error
}

ErrDecodeFailed is the decode failed error.

func (*ErrDecodeFailed) Error

func (err *ErrDecodeFailed) Error() string

Error satisfies the error interface.

func (*ErrDecodeFailed) Unwrap

func (err *ErrDecodeFailed) Unwrap() error

Unwrap satisfies the unwrap interface.

type ErrInsertFailed

type ErrInsertFailed struct {
	Err error
}

ErrInsertFailed is the insert failed error.

func (*ErrInsertFailed) Error

func (err *ErrInsertFailed) Error() string

Error satisfies the error interface.

func (*ErrInsertFailed) Unwrap

func (err *ErrInsertFailed) Unwrap() error

Unwrap satisfies the unwrap interface.

type ErrUpdateFailed

type ErrUpdateFailed struct {
	Err error
}

ErrUpdateFailed is the update failed error.

func (*ErrUpdateFailed) Error

func (err *ErrUpdateFailed) Error() string

Error satisfies the error interface.

func (*ErrUpdateFailed) Unwrap

func (err *ErrUpdateFailed) Unwrap() error

Unwrap satisfies the unwrap interface.

type ErrUpsertFailed

type ErrUpsertFailed struct {
	Err error
}

ErrUpsertFailed is the upsert failed error.

func (*ErrUpsertFailed) Error

func (err *ErrUpsertFailed) Error() string

Error satisfies the error interface.

func (*ErrUpsertFailed) Unwrap

func (err *ErrUpsertFailed) Unwrap() error

Unwrap satisfies the unwrap interface.

type Error

type Error string

Error is an error.

const (
	// ErrAlreadyExists is the already exists error.
	ErrAlreadyExists Error = "already exists"
	// ErrDoesNotExist is the does not exist error.
	ErrDoesNotExist Error = "does not exist"
	// ErrMarkedForDeletion is the marked for deletion error.
	ErrMarkedForDeletion Error = "marked for deletion"
)

Error values.

const ErrInvalidStringSlice Error = "invalid StringSlice"

ErrInvalidStringSlice is the invalid StringSlice error.

func (Error) Error

func (err Error) Error() string

Error satisfies the error interface.

type News

type News struct {
	ID          int       `db:"id"`          // id
	Title       string    `db:"title"`       // title
	Description string    `db:"description"` // description
	CreatedAt   time.Time `db:"created_at"`  // created_at
	UpdatedAt   time.Time `db:"updated_at"`  // updated_at
}

News represents a row from 'public.news'.

func NewNews

func NewNews(
	ID int,
	Title string,
	Description string,
	CreatedAt time.Time,
	UpdatedAt time.Time,
) *News

func NewsByID

func NewsByID(ctx context.Context, idb interface{}, id int) (*News, error)

NewsByID retrieves a row from 'public.news' as a News.

Generated from index 'news_pkey'.

func (*News) BulkInsert

func (n *News) BulkInsert(ctx context.Context, idb interface{}, rows []News, now time.Time) error

BulkInsert inserts the News to the database.

func (*News) Delete

func (n *News) Delete(ctx context.Context, idb interface{}, now time.Time) error

Delete deletes the News from the database.

func (*News) Insert

func (n *News) Insert(ctx context.Context, idb interface{}, now time.Time) error

Insert inserts the News to the database.

func (*News) Update

func (n *News) Update(ctx context.Context, idb interface{}, now time.Time) error

Update updates a News in the database.

func (*News) Upsert

func (n *News) Upsert(ctx context.Context, idb interface{}, now time.Time) error

Upsert performs an upsert for News.

type StringSlice

type StringSlice []string

StringSlice is a slice of strings.

func (*StringSlice) Scan

func (ss *StringSlice) Scan(v interface{}) error

Scan satisfies the sql.Scanner interface for StringSlice.

func (StringSlice) Value

func (ss StringSlice) Value() (driver.Value, error)

Value satisfies the sql/driver.Valuer interface.

Jump to

Keyboard shortcuts

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