Documentation
¶
Overview ¶
Package sqlp is a custom orm for Go that uses reflection to map structs to database tables. Heavy work in progress. Breaking changes every week. No tests. No documentation. No optimization (20-30% slower than native). No guarantees. Do not use.
Index ¶
- func Delete[T Repo](pk any) error
- func DeleteObj[T Repo](obj T) error
- func GetAll[T Repo]() ([]T, error)
- func GetAllWhere[T Repo](where string, args ...any) ([]T, error)
- func GetByPk[T Repo](pk any) (T, error)
- func GetSingleWhere[T Repo](where string, args ...any) (res T, err error)
- func Insert[T Repo](obj T) (int, error)
- func Query[T any](query string, args ...any) (results []T, err error)
- func QueryBasic[T string | int | int64 | float32 | float64](query string, args ...any) (results []T, err error)
- func QueryBasicRow[T string | int | int64 | float32 | float64](query string, args ...any) (result T, err error)
- func QueryRow[T any](query string, args ...any) (result T, err error)
- func SetDatabase(sqldb *sql.DB)
- func Update[T Repo](obj T) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Delete ¶ added in v0.1.2
Delete deletes the row in the table that the Repo type maps to based on the given primary key.
func DeleteObj ¶ added in v0.1.25
func DeleteObj[T Repo](obj T) error
DeleteObj deletes the row in the table that the Repo type maps to based on the primary key of the given object.
func GetAll ¶ added in v0.1.25
func GetAll[T Repo]() ([]T, error)
GetAll retrieves all rows from the table that the Repo type maps to.
func GetAllWhere ¶ added in v0.1.25
GetAllWhere retrieves all rows from the table that the Repo type maps to, where the where clause is true. The clause should start with "WHERE" or "ORDERBY".
func GetByPk ¶ added in v0.1.25
GetByPk retrieves a single row from the table that the Repo type maps to, where the primary key matches the given value.
func GetSingleWhere ¶ added in v0.1.25
GetSingleWhere retrieves the first row from the table that the Repo type maps to that matches the where clause. The clause should start with "WHERE" or "ORDERBY".
func QueryBasic ¶
func QueryBasicRow ¶ added in v0.1.4
func SetDatabase ¶
SetDatabase sets the global database handle to be used by the Query function.
Types ¶
This section is empty.