operations

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Errors errorConfig

Functions

func CreateRow

func CreateRow(connector gotabase.Connector, query string, args ...any) error

CreateRow creates a new data in the database.

func CreateRowWithId

func CreateRowWithId[TId any, T HasIdSetter[TId]](connector gotabase.Connector, object T, query string, args ...any) error

CreateRowWithId creates a new data in the database. The query is expected to return a new id, that will be set in the object using the HasIdSetter interface method.

func CreateRowWithScan

func CreateRowWithScan[T any](connector gotabase.Connector, object T, scanner func(row gotabase.Row, object T) error, query string, args ...any) error

CreateRowWithScan creates a new data in the database. The query is expected to return a row, that will match the provided scanner function.

func DeleteRow

func DeleteRow(connector gotabase.Connector, query string, args ...any) error

DeleteRow runs the query to remove a single row from the database. If none or more than one row are affected, then error will be returned.

func DeleteRows

func DeleteRows(connector gotabase.Connector, query string, args ...any) error

DeleteRows runs the query to remove at last one row from the database. If none or more than one row are affected, then error will be returned.

func QueryRow

func QueryRow[T any](connector gotabase.Connector, scanner func(row gotabase.Row) (*T, error), query string, args ...any) (*T, error)

QueryRow is a helper function to run a single row query.

func QueryRows

func QueryRows[T any](connector gotabase.Connector, scanner func(row gotabase.Row) (*T, error), query string, args ...any) ([]*T, error)

QueryRows is a helper function to run a multiple rows query based on a query string.

func TryDelete

func TryDelete(connector gotabase.Connector, query string, args ...any) error

TryDelete runs the query attempting to delete something. If the query runs successfully, no error is returned, regardless of the number of affected rows.

func UpdateRow

func UpdateRow(connector gotabase.Connector, query string, args ...any) error

UpdateRow runs the query to update a single row in the database. If none or more than one row are updated, then error will be returned.

Types

type HasIdSetter

type HasIdSetter[T any] interface {
	SetId(id T)
}

Jump to

Keyboard shortcuts

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