daggertech

package module
v0.0.0-...-532c0ef Latest Latest
Warning

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

Go to latest
Published: May 23, 2023 License: GPL-3.0 Imports: 11 Imported by: 3

README

dagger

ORM for Golang/SQL with memory cache

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Configure

func Configure(c *Config) bool

Configure loads the configraution for connection to the database. This must be done before all other database operations

func Count

func Count(t string, c *Criteria) int

Count returns the number of records in the named table that match the criteria

func Fetch

func Fetch[T Modeller](m T, c *Criteria) ([]T, bool)

Fetch populates the slice with models from the database that match the criteria. Returns false if this fails

func First

func First[T Modeller](m T, c *Criteria) (T, bool)

First populates the model with the first record from the database that match the criteria. Returns false if this fails or there is no record to return

func RawExecute

func RawExecute(sql string) bool

RawExecute executes a sql statement on the database, without returning a value Not recommended for general use - can break shadowing

func RawScalar

func RawScalar(sql string) (interface{}, bool)

RawScalar exeutes a raw sql statement that returns a single value Not recommended for general use

func RawSelect

func RawSelect(sql string) []map[string]interface{}

RawSelect executes a raw sql statement on the database Not recommended for general use

func Remove

func Remove(m Modeller) bool

Remove deletes the model from the database

func RemoveMany

func RemoveMany(t string, c *Criteria) (int, bool)

RemoveMany removes all records from the named table that match the criteria

func Save

func Save(m Modeller) bool

Save stores the model in the database

Types

type Config

type Config struct {
	// contains filtered or unexported fields
}

Config is the database configuration

func CreateConfig

func CreateConfig(host string, name, user, password string, allowDelete bool) *Config

CreateConfig prepares the configuration for dagger

type Criteria

type Criteria struct {
	Where      interface{}
	Order      interface{}
	Limit      int
	Offset     int
	IncDeleted bool
}

Criteria is used to safely build your criteria for searches

type Model

type Model struct {
	ID         *string
	CreateDate time.Time
	LastUpdate time.Time
	DeleteDate *time.Time
	// contains filtered or unexported fields
}

Model is the base for all database models

func CreateModel

func CreateModel() Model

CreateModel sets the default parameters for the Model

func (Model) GetID

func (m Model) GetID() *string

GetID returns the ID of the model

func (Model) IsDeleted

func (m Model) IsDeleted() bool

IsDeleted returns true if teh model has been marked as deleted

func (Model) IsNew

func (m Model) IsNew() bool

IsNew returns true if the model has yet to be stored

func (Model) StandingData

func (m Model) StandingData() []Modeller

StandingData returns the standing data for when the table is created

type ModelState

type ModelState int

ModelState is the state of the current model

type Modeller

type Modeller interface {
	// StandingData returns the standing data for the model
	StandingData() []Modeller

	// GetID returns the ID of the model
	GetID() *string

	// IsNew returns true if the model has yet to be saved
	IsNew() bool

	// IsDeleted returns true if the model has been marked as deleted
	IsDeleted() bool
}

Modeller defines the common functionality of a Model

Directories

Path Synopsis
Package clause This is a very basic, and yet versatile ORM package.
Package clause This is a very basic, and yet versatile ORM package.
Package order This is a very basic, and yet versatile ORM package.
Package order This is a very basic, and yet versatile ORM package.

Jump to

Keyboard shortcuts

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