orm

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2024 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const COUNTDOWN = 5
View Source
const INSTANT_ENV = "ORM_INSTANT"
View Source
const MIGRATE_ENV = "ORM_MIGRATE"

Variables

View Source
var EmptyErr = errors.New("Result is empty")

Functions

func Entities added in v1.0.1

func Entities[T tables.Table](db *DB, table *[]T, query string) error

func IsPragmaEmpty

func IsPragmaEmpty(rows pragma) bool

func SingleEntity added in v1.0.1

func SingleEntity[T tables.Table](db *DB, table *T, query string) error

Types

type DB

type DB struct {

	// The slice of registered tables.
	//
	// Modify it DIRECTLY, because why build useless interfaces.
	Tables []tables.Table
	// contains filtered or unexported fields
}

Database handle wrapper.

func NewDB

func NewDB(db *sqlx.DB) *DB

Create a new DB object using the handle.

Note: Don't forget to add your table.Table-s into DB.Tables after creation!

In order to use the migration functionality, call DB.GenMigrations()

func (*DB) ApplyMigrations

func (db *DB) ApplyMigrations(migrations []string, altered bool) error

func (*DB) ApplyMigrationsNow

func (db *DB) ApplyMigrationsNow(migrations []string, altered bool) error

func (*DB) Exec

func (db *DB) Exec(query string, args ...any) error

func (*DB) Fields

func (db *DB) Fields(query string, table tables.Table, fields ...string) (fields, error)

func (*DB) GenMigrations

func (db *DB) GenMigrations() error

func (*DB) Handle

func (db *DB) Handle() *sqlx.DB

Access the underlying *sqlx.DB directly

func (*DB) InsertEntity

func (db *DB) InsertEntity(table tables.Table) error

func (*DB) PragmaOf

func (db *DB) PragmaOf(table tables.Table) (pragma, error)

func (*DB) Select

func (db *DB) Select(dest interface{}, query string) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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