aorm

package module
v1.9.2-0...-397750e Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2020 License: MIT Imports: 30 Imported by: 34

README

AORM

The fantastic Advanced ORM library for Golang, aims to be developer friendly.

This is a fork of GORM with improved performance and many other features.

go report card wercker status Open Collective Backer Open Collective Sponsor MIT license GoDoc

Overview

  • Full-Featured ORM (almost)
  • Associations (Has One, Has Many, Belongs To, Many To Many, Polymorphism)
  • Hooks (Before/After Create/Save/Update/Delete/Find)
  • Preloading (eager loading)
  • Transactions
  • Composite Primary Key
  • SQL Builder
  • Auto Migrations
  • Logger
  • Extendable, write Plugins based on GORM callbacks
  • Every feature comes with tests
  • Developer Friendly
  • NEW: Inline model loader and auto loader
  • NEW: Null values scaner without Nullable Field
  • NEW: Log callbacks
  • NEW: After scanner callbacks
  • NEW: Binary ID (using bid.BID)
  • NEW: Index/Unique Index withe WHERE clause
  • NEW: Raw args binder
  • NEW: Custom arg binder by dialect
  • NEW: Custom arg valuer by dialect
  • NEW: POLYMORPHIC_VALUE tag: sql:"POLYMORPHIC_VALUE:user" or singular and plural: sql:"POLYMORPHIC_VALUE:user,users"
  • NEW: Dry Run db.DryRun().First(&user)
  • NEW: Model Struct Api: aorm.StructOf(&User{})
  • NEW: Model Struct interface: aorm.InstaceOf(&User{})
  • NEW: ID Api: aorm.IdOf(&User{ID:1})
  • NEW: Get executed query and args fmt.Println(db.First(&user).Query) or fmt.Println(db.DryRun().First(&user).Query)
  • NEW: Readonly fields with select query
  • NEW: Args and Query API db.First(&user, aorm.Query{"name = ?", []interface{}{"joe"}}) or your type implements aorm.Clauser
  • NEW: Money type
  • NEW: Dynamic table namer
  • NEW: and more other changes...

Installation

WINDOWS NOTE: run these commands inside CygWin or Git Bash.

go get -u github.com/moisespsena-go/aorm
cd $GOPATH/github.com/moisespsena-go/aorm
go generate
GO DEP

If uses dep for manage your dependencies, runs:

cd YOUR_PROJECT_DIR
dep ensure -add github.com/moisespsena-go/aorm
cd vendor/github.com/moisespsena-go/aorm
go generate

Getting Started

Contributing

You can help to deliver a better GORM, check out things you can do

License

© Moises P. Sena, 2018~time.Now

Released under the MIT License

Documentation

Index

Examples

Constants

View Source
const (
	AuditedFieldCreatedByID = "CreatedByID"
	AuditedFieldUpdatedByID = "UpdatedByID"

	AuditedColumnCreatedByID = "created_by_id"
	AuditedColumnUpdatedByID = "updated_by_id"

	AuditedFieldCreatedAt = "CreatedAt"
	AuditedFieldUpdatedAt = "UpdatedAt"

	AuditedColumnCreatedAt = "created_at"
	AuditedColumnUpdatedAt = "updated_at"
)
View Source
const (
	OptSkipPreload = "aorm:skip_preload"
	OptAutoPreload = "aorm:auto_preload"
)
View Source
const (
	DefaultQuoter = QuoteRuner('`')
	QuoteCharS    = string(DefaultQuoter)
)
View Source
const (
	LOG_CREATE = "create"
	LOG_READ   = "read"
	LOG_UPDATE = "update"
	LOG_DELETE = "delete"
	LOG_QUERY  = "query"
	LOG_EXEC   = "exec"
)
View Source
const (
	SoftDeleteFieldDeletedByID = "DeletedByID"
	SoftDeleteFieldDeletedAt   = "DeletedAt"

	SoftDeletedColumnDeletedByID = "deleted_by_id"
	SoftDeleteColumnDeletedAt    = "deleted_at"
)
View Source
const (
	TimestampFieldCreatedAt = "CreatedAt"
	TimestampFieldUpdatedAt = "UpdatedAt"

	TimestampColumnCreatedAt = "created_at"
	TimestampColumnUpdatedAt = "updated_at"
)
View Source
const (
	CbGenId = ""
)
View Source
const (
	StoreBlankField = "aorm:store_blank_field"
)

Variables

View Source
var (
	// ErrRecordNotFound record not found error, happens when haven'T find any matched data when looking up with a struct
	ErrRecordNotFound = errors.New("record not found")
	// ErrInvalidSQL invalid SQL error, happens when you passed invalid SQL
	ErrInvalidSQL = errors.New("invalid SQL")
	// ErrInvalidTransaction invalid transaction when you are trying to `Commit` or `Rollback`
	ErrInvalidTransaction = errors.New("no valid transaction")
	// ErrCantStartTransaction can'T start transaction when you are trying to start one with `Begin`
	ErrCantStartTransaction = errors.New("can'T start transaction")
	// ErrUnaddressable unaddressable value
	ErrUnaddressable = errors.New("using unaddressable value")
	// ErrSingleUpdateKey single UPDATE require primary key value
	ErrSingleUpdateKey = errors.New("Single UPDATE require primary key value.")
)
View Source
var (
	SoftDeleteFields = []string{
		SoftDeleteFieldDeletedByID,
		SoftDeleteFieldDeletedAt,
	}

	AuditedSDFields = append(append([]string{}, AuditedFields...), SoftDeleteFields...)
)
View Source
var DefaultCallback = &Callback{}

DefaultCallback default callbacks defined by gorm

View Source
var DefaultLogger = &ScopeLoggers{}
View Source
var DefaultTableNameHandler = func(ctx context.Context, singular bool, modelStruct *ModelStruct) (tableName string) {
	if singular {
		return modelStruct.SingularTableName
	}
	return modelStruct.PluralTableName
}

DefaultTableNameHandler default table name handler

View Source
var LogFormatter = func(values ...interface{}) (messages []interface{}) {
	if len(values) > 1 {
		var (
			sql             string
			formattedValues []string
			level           = values[0]
			currentTime     = "\n\033[33m[" + NowFunc().Format("2006-01-02 15:04:05") + "]\033[0m"
			source          = fmt.Sprintf("\033[35m(%v)\033[0m", values[1])
		)

		messages = []interface{}{source, currentTime}

		if level == "sql" {

			messages = append(messages, fmt.Sprintf(" \033[36;1m[%.2fms]\033[0m ", float64(values[2].(time.Duration).Nanoseconds()/1e4)/100.0))

			for _, value := range values[4].([]interface{}) {
				indirectValue := reflect.Indirect(reflect.ValueOf(value))
				if indirectValue.IsValid() {
					value = indirectValue.Interface()
					if t, ok := value.(time.Time); ok {
						formattedValues = append(formattedValues, fmt.Sprintf("'%v'", t.Format("2006-01-02 15:04:05")))
					} else if b, ok := value.([]byte); ok {
						if str := string(b); isPrintable(str) {
							formattedValues = append(formattedValues, fmt.Sprintf("'%v'", str))
						} else {
							formattedValues = append(formattedValues, "'<binary>'")
						}
					} else if r, ok := value.(driver.Valuer); ok {
						if value, err := r.Value(); err == nil && value != nil {
							formattedValues = append(formattedValues, fmt.Sprintf("'%v'", value))
						} else {
							formattedValues = append(formattedValues, "NULL")
						}
					} else {
						formattedValues = append(formattedValues, fmt.Sprintf("'%v'", value))
					}
				} else {
					formattedValues = append(formattedValues, "NULL")
				}
			}

			if numericPlaceHolderRegexp.MatchString(values[3].(string)) {
				sql = values[3].(string)
				for index, value := range formattedValues {
					placeholder := fmt.Sprintf(`\$%d([^\d]|$)`, index+1)
					sql = regexp.MustCompile(placeholder).ReplaceAllString(sql, value+"$1")
				}
			} else {
				formattedValuesLength := len(formattedValues)
				for index, value := range sqlRegexp.Split(values[3].(string), -1) {
					sql += value
					if index < formattedValuesLength {
						sql += formattedValues[index]
					}
				}
			}

			messages = append(messages, sql)
			messages = append(messages, fmt.Sprintf(" \n\033[36;31m[%v]\033[0m ", strconv.FormatInt(values[5].(int64), 10)+" rows affected or returned "))
		} else {
			messages = append(messages, "\033[31;1m")
			messages = append(messages, values[2:]...)
			messages = append(messages, "\033[0m")
		}

		return
	}

	return values
}
View Source
var NowFunc = func() time.Time {
	return time.Now()
}

NowFunc returns current time, this function is exported in order to be able to give the flexibility to the developer to customize it according to their needs, e.g:

aorm.NowFunc = func() time.Time {
  return time.Now().UTC()
}
View Source
var ParseFieldStructForDialect = func(field *FieldStructure, dialect Dialector) (fieldValue reflect.Value, sqlType string, size int, additionalType string) {
	// Get redirected field type
	var (
		reflectType = field.Type
		dataType    = field.TagSettings["TYPE"]
	)

	for reflectType.Kind() == reflect.Ptr {
		reflectType = reflectType.Elem()
	}

	if dataType != "" {
		switch reflectType.Kind() {
		case reflect.String:
			dataType = AbbrToTextType(dataType)
		}
	}

	if dataType == "" && field.Assigner != nil {
		dataType = field.Assigner.SQLType(dialect)
	}

	fieldValue = reflect.Indirect(reflect.New(reflectType))

	if dataTyper, ok := fieldValue.Interface().(DbDataTyper); ok {
		dataType = dataTyper.AormDataType(dialect)
	}

	if dataType == "" {
		var getScannerValue func(reflect.Value)
		getScannerValue = func(value reflect.Value) {
			fieldValue = value
			if _, isScanner := reflect.New(fieldValue.Type()).Interface().(sql.Scanner); isScanner && fieldValue.Kind() == reflect.Struct {
				getScannerValue(fieldValue.Field(0))
			}
		}
		getScannerValue(fieldValue)
	}

	if num, ok := field.TagSettings["SIZE"]; ok {
		size, _ = strconv.Atoi(num)
	} else if sizer, ok := field.Assigner.(SQLSizer); ok {
		size = sizer.SQLSize(dialect)
	} else {
		size = 255
	}

	additionalType = field.TagSettings["NOT NULL"] + " " + field.TagSettings["UNIQUE"]
	if value, ok := field.TagSettings["DEFAULT"]; ok {

		if value != "DEFAULT" {
			additionalType = additionalType + " DEFAULT " + value
		}
	}

	return fieldValue, dataType, size, strings.TrimSpace(additionalType)
}

ParseFieldStructForDialect get field's sql data type

View Source
var StructFieldMethodCallbacks = NewStructFieldMethodCallbacksRegistrator()

StructFieldMethodCallbacks is a default registrator for model fields callbacks where the field type is a struct and have a callback method. Default methods callbacks: AfterScan: Call method `AfterScanMethodCallback` after scan field from sql row.

Functions

func AbbrToTextType

func AbbrToTextType(abbr string) string

func AcceptTypeForModelStruct

func AcceptTypeForModelStruct(typ interface{}) (ok bool)

func AcceptableTypeForModelStructInterface

func AcceptableTypeForModelStructInterface(i interface{}) (typ reflect.Type)

func AfterScanMethodCallback

func AfterScanMethodCallback(_ *Method, method interface{}, field *Field, scope *Scope)
Example
package main

import ()

func main() {
	println(`
package main

import (
	"reflect"
	"github.com/moisespsena-go/aorm"
	"database/sql/driver"
	_ "github.com/moisespsena-go/aorm/dialects/sqlite"
	"strconv"
	"strings"
)

type Media struct {
	Name      string
	baseUrl   *string
	modelType reflect.Type
	model interface {
		GetID() int
	}
	fieldName *string
}

func (image *Media) Scan(value interface{}) error {
	image.Name = string(value.([]byte))
	return nil
}

func (image *Media) Value() (driver.Value, error) {
	return image.Name, nil
}

func (image *Media) AfterScan(scope *aorm.Scope, field *aorm.Field) {
	image.fieldName, image.model = &field.StructField.Name, scope.Val.(interface {
		GetID() int
	})
	baseUrl, _ := scope.DB().Get("base_url")
	image.baseUrl = baseUrl.(*string)
	image.modelType = reflect.TypeOf(scope.Val)
	for image.modelType.Kind() == reflect.Ptr {
		image.modelType = image.modelType.Elem()
	}
}

func (image *Media) URL() string {
	return strings.Join([]string{*image.baseUrl, image.modelType.Name(), strconv.Itoa(image.model.GetID()),
		*image.fieldName, image.Name}, "/")
}

type User struct {
	BID        int
	MainImage Media
}

func (user *User) GetID() int {
	return user.BID
}

func main() {
	// register media type
	aorm.StructFieldMethodCallbacks.RegisterFieldType(&Media{})

	db, err := aorm.Open("sqlite3", "db.db")
	if err != nil {
		panic(err)
	}

	db.AutoMigrate(&User{})

	baseUrl := "http://example.com/media"
	db = db.Set("base_url", &baseUrl)

	var model User
	db_ := db.Where("id = ?", 1).First(&model)
	if db_.RecordNotFound() {
		db.Save(&User{MainImage: Media{Name: "picture.jpg"}})
		err = db.Where("id = ?", 1).First(&model).error
		if err != nil {
			panic(err)
		}
	} else if db_.error != nil {
		panic(db_.error)
	}

	println("Media URL:", model.MainImage.URL())
}
`)
}
Output:

func BindVar

func BindVar(dialect Dialector, assigner Assigner, value interface{}, replacement string) string

func BindVarStructure

func BindVarStructure(dialect Dialector, field *FieldStructure, replacement string) string

func Each

func Each(it RecordsIterator, cb func(i int, r interface{}) error) (err error)

func ErrorByType

func ErrorByType(expected reflect.Type, err ...error) (theError error)

func ExcludeTypeForModelStruct

func ExcludeTypeForModelStruct(typ ...interface{})

func IDValueRawConverterRegister

func IDValueRawConverterRegister(typ reflect.Type, converter IDValueRawConverter)

func IdStringTo

func IdStringTo(id string, value interface{}) error

IdStringTo parses id from strign and set it to model value

func InID

func InID(id ...ID) *idSliceScoper

func InIDNamedTable

func InIDNamedTable(tableName string, id ...ID) *idSliceNamedTable

func InlinePreloadCallback

func InlinePreloadCallback(scope *Scope)

func InlinePreloadFieldsKeyOf

func InlinePreloadFieldsKeyOf(value interface{}) string

func IsBlank

func IsBlank(value reflect.Value) bool

func IsByteArrayOrSlice

func IsByteArrayOrSlice(value reflect.Value) bool

IsByteArrayOrSlice returns true of the reflected value is an array or slice

func IsDuplicateUniqueIndexError

func IsDuplicateUniqueIndexError(err ...error) bool

func IsError

func IsError(expected error, err ...error) (is bool)

func IsErrorTyp

func IsErrorTyp(expected reflect.Type, err ...error) (is bool)

func IsManyResult

func IsManyResult(dst interface{}) (many bool)

func IsQueryError

func IsQueryError(err ...error) bool

func IsRecordNotFoundError

func IsRecordNotFoundError(err error) bool

IsRecordNotFoundError returns current error has record not found error or not

func Iterate

func Iterate(it RecordsIterator) (err error)

func M2MNameOf

func M2MNameOf(a reflect.Type, b reflect.Type) (prefix, name string)

func M2MNameOfString

func M2MNameOfString(aName, bName string) (prefix, name string)

func OpenIterate

func OpenIterate(opener RecordsIteratorOpener) (err error)

func PathsFromQuery

func PathsFromQuery(query string) (paths []string)

func Quote

func Quote(q Quoter, key string) string

Quote quotes field name to avoid SQL parsing exceptions by using a reserved word as a field name

func QuoteConvert

func QuoteConvert(q Quoter, s string) string

QuoteConvert converts all characters equals QuoteChar in string to quote char

func QuoteConvertChar

func QuoteConvertChar(q Quoter, fromChar string, s string) string

QuoteConvertChar converts all characters equals fromChar in string to quote char

func Register

func Register(assigner ...Assigner)

func RegisterDialect

func RegisterDialect(name string, dialect Dialector)

RegisterDialect register new dialect

func SenderOf

func SenderOf(value reflect.Value) (send func(el reflect.Value))

func SetIdCallback

func SetIdCallback(scope *Scope)

func SetNonZero

func SetNonZero(rvalue reflect.Value, value interface{})

func SetZero

func SetZero(rvalue reflect.Value)

func StructTypeOf

func StructTypeOf(value reflect.Type) (typ reflect.Type, many, ptr bool)

func StructTypeOfInterface

func StructTypeOfInterface(value interface{}) (typ reflect.Type, many, ptr bool)

func ToDBName

func ToDBName(name string) string

ToDBName convert string to db name

func TupleQueryArgs

func TupleQueryArgs(argCount int) (query string)

TupleQueryArgs create tuple args from argCount

func ValuerFunc

func ValuerFunc(f func() (driver.Value, error)) driver.Valuer

func WalkErr

func WalkErr(cb func(err error) (stop bool), errs ...error) (stop bool)

func ZeroIdOf

func ZeroIdOf(value interface{}) bool

ZeroIdOf returns if ID of model value is zero

Types

type AfterInlinePreloadScanner

type AfterInlinePreloadScanner interface {
	AormAfterInlinePreloadScan(ip *InlinePreloader, recorde, value interface{})
}

type Alias

type Alias struct {
	Expr string
	Name string
}

type AormNonFieldStructor

type AormNonFieldStructor interface {
	AormNonFieldStructor()
}

type ArgBinder

type ArgBinder interface {
	DbBindVar(dialect Dialector, argVar string) string
}

type AssignArgBinder

type AssignArgBinder interface {
	Assigner
	ArgBinder
}

type Assigner

type Assigner interface {
	Valuer(dialect Dialector, value interface{}) driver.Valuer
	Scaner(dialect Dialector, dest reflect.Value) Scanner
	SQLType(dialect Dialector) string
	Type() reflect.Type
}

type AssignerRegistrator

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

func Assigners

func Assigners() *AssignerRegistrator

func (*AssignerRegistrator) ApplyToDialect

func (a *AssignerRegistrator) ApplyToDialect(dialect Dialector)

func (*AssignerRegistrator) Get

func (a *AssignerRegistrator) Get(typ reflect.Type) (assigner Assigner)

func (*AssignerRegistrator) Has

func (a *AssignerRegistrator) Has(typ reflect.Type) (ok bool)

func (*AssignerRegistrator) Of

func (a *AssignerRegistrator) Of(value interface{}) (assigner Assigner)

func (*AssignerRegistrator) Register

func (a *AssignerRegistrator) Register(assigners ...Assigner)

type Association

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

Association Mode contains some helper methods to handle relationship things easily.

func (*Association) Append

func (this *Association) Append(values ...interface{}) *Association

Append append new associations for many2many, has_many, replace current association for has_one, belongs_to

func (*Association) Clear

func (this *Association) Clear() *Association

Clear remove relationship between source & current associations, won'T delete those associations

func (*Association) Count

func (this *Association) Count() int

Count return the count of current associations

func (*Association) Delete

func (this *Association) Delete(values ...interface{}) *Association

Delete remove relationship between source & passed arguments, but won'T delete those arguments

func (*Association) Error

func (this *Association) Error() error

func (*Association) Find

func (this *Association) Find(value interface{}) *Association

Find find out all related associations

func (*Association) HasError

func (this *Association) HasError() bool

func (*Association) Replace

func (this *Association) Replace(values ...interface{}) *Association

Replace replace current associations with new one

type Audited

type Audited struct {
	CreatedByID bid.BID
	UpdatedByID bid.BID
	Timestamps
}

func (*Audited) GetCreatedBy

func (a *Audited) GetCreatedBy() IDValuer

func (*Audited) GetUpdatedBy

func (a *Audited) GetUpdatedBy() IDValuer

func (*Audited) SetCreatedBy

func (a *Audited) SetCreatedBy(value IDValuer)

func (*Audited) SetUpdatedBy

func (a *Audited) SetUpdatedBy(value IDValuer)

type AuditedModel

type AuditedModel struct {
	Model
	Audited
}

type AuditedSD

type AuditedSD struct {
	Audited
	SoftDeleteAudited
}

type AuditedSDModel

type AuditedSDModel struct {
	Model
	AuditedSD
}

type Auditor

type Auditor interface {
	Timestamper
	SetCreatedBy(createdBy IDValuer)
	GetCreatedBy() IDValuer
	SetUpdatedBy(updatedBy IDValuer)
	GetUpdatedBy() IDValuer
}

type BIDAssigner

type BIDAssigner struct {
}

func (BIDAssigner) DbBindVar

func (a BIDAssigner) DbBindVar(dialect Dialector, argVar string) string

func (BIDAssigner) FromRaw

func (BIDAssigner) FromRaw(raw interface{}) IDValuer

func (BIDAssigner) SQLSize

func (BIDAssigner) SQLSize(_ Dialector) int

func (BIDAssigner) SQLType

func (BIDAssigner) SQLType(dialect Dialector) string

func (BIDAssigner) Scaner

func (BIDAssigner) Scaner(_ Dialector, dest reflect.Value) Scanner

func (BIDAssigner) ToRaw

func (BIDAssigner) ToRaw(value IDValuer) interface{}

func (BIDAssigner) Type

func (BIDAssigner) Type() reflect.Type

func (BIDAssigner) Valuer

func (BIDAssigner) Valuer(dialect Dialector, value interface{}) driver.Valuer

type BIDIdValuer

type BIDIdValuer BytesId

func (BIDIdValuer) Bytes

func (this BIDIdValuer) Bytes() []byte

func (BIDIdValuer) IsZero

func (this BIDIdValuer) IsZero() bool

func (BIDIdValuer) ParseBytes

func (BIDIdValuer) ParseBytes(b []byte) (IDValuer, error)

func (BIDIdValuer) ParseString

func (BIDIdValuer) ParseString(s string) (_ IDValuer, err error)

func (BIDIdValuer) Raw

func (this BIDIdValuer) Raw() interface{}

func (BIDIdValuer) String

func (this BIDIdValuer) String() string

type BytesId

type BytesId []byte

func (BytesId) Bytes

func (this BytesId) Bytes() []byte

func (BytesId) IsZero

func (this BytesId) IsZero() bool

func (BytesId) ParseBytes

func (BytesId) ParseBytes(b []byte) (IDValuer, error)

func (BytesId) ParseString

func (BytesId) ParseString(s string) (_ IDValuer, err error)

func (BytesId) Raw

func (this BytesId) Raw() interface{}

func (BytesId) String

func (this BytesId) String() string

type BytesParser

type BytesParser interface {
	ParseBytes(b []byte) error
}

type Callback

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

Callback is a struct that contains all CRUD callbacks

Field `creates` contains callbacks will be call when creating object
Field `updates` contains callbacks will be call when updating object
Field `deletes` contains callbacks will be call when deleting object
Field `queries` contains callbacks will be call when querying object with query methods like Find, First, Related, Association...
Field `rowQueries` contains callbacks will be call when querying object with Row, Rows...
Field `processors` contains all callback processors, will be used to generate above callbacks in order

func (*Callback) Create

func (c *Callback) Create() *CallbackProcessor

Create could be used to register callbacks for creating object

db.Callback().Create().After("aorm:create").Register("plugin:run_after_create", func(*Scope) {
  // business logic
  ...

  // set error if some thing wrong happened, will rollback the creating
  scope.Err(errors.New("error"))
})

func (*Callback) Delete

func (c *Callback) Delete() *CallbackProcessor

Delete could be used to register callbacks for deleting object, refer `Create` for usage

func (*Callback) Query

func (c *Callback) Query() *CallbackProcessor

Query could be used to register callbacks for querying objects with query methods like `Find`, `First`, `Related`, `Association`... Refer `Create` for usage

func (*Callback) RowQuery

func (c *Callback) RowQuery() *CallbackProcessor

RowQuery could be used to register callbacks for querying objects with `Row`, `Rows`, refer `Create` for usage

func (*Callback) Update

func (c *Callback) Update() *CallbackProcessor

Update could be used to register callbacks for updating object, refer `Create` for usage

type CallbackProcessor

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

CallbackProcessor contains callback informations

func (*CallbackProcessor) After

func (cp *CallbackProcessor) After(callbackName string) *CallbackProcessor

After insert a new callback after callback `callbackName`, refer `Callbacks.Create`

func (*CallbackProcessor) Before

func (cp *CallbackProcessor) Before(callbackName string) *CallbackProcessor

Before insert a new callback before callback `callbackName`, refer `Callbacks.Create`

func (*CallbackProcessor) Get

func (cp *CallbackProcessor) Get(callbackName string) (callback func(scope *Scope))

Get registered callback

db.Callback().Create().Get("aorm:create")

func (*CallbackProcessor) Register

func (cp *CallbackProcessor) Register(callbackName string, callback func(scope *Scope))

Register a new callback, refer `Callbacks.Create`

func (*CallbackProcessor) Remove

func (cp *CallbackProcessor) Remove(callbackName string)

Remove a registered callback

db.Callback().Create().Remove("aorm:update_time_stamp_when_create")

func (*CallbackProcessor) Replace

func (cp *CallbackProcessor) Replace(callbackName string, callback func(scope *Scope))

Replace a registered callback with new callback

    db.Callback().Create().Replace("aorm:update_time_stamp_when_create", func(*Scope) {
		   scope.SetColumn("Created", now)
		   scope.SetColumn("Updated", now)
    })

type Clause

type Clause struct {
	Query interface{}
	Args  []interface{}
}

func (*Clause) BuildCondition

func (clause *Clause) BuildCondition(scope *Scope, include bool) (result Query)

type ClauseScoper

type ClauseScoper interface {
	TableNamer
	ToVarsAppender
	QuotedTableName() string
	Struct() *ModelStruct
	Instance() *Instance
	ScopeOfField(fieldName string) *Scope
}

type Clauser

type Clauser interface {
	Clause(scope *Scope) (result Query)
}

type ColumnDismissibleTypeScaner

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

type ColumnDismissibleTypeScanerHandler

type ColumnDismissibleTypeScanerHandler interface {
	Scaner(scope *Scope, record interface{}, column string) sql.Scanner
}

type Conditions

type Conditions struct {
	Args Vars
	// contains filtered or unexported fields
}

func NewConditions

func NewConditions() *Conditions

func (*Conditions) MergeTo

func (this *Conditions) MergeTo(db *DB) *DB

func (*Conditions) Not

func (this *Conditions) Not(query interface{}, values ...interface{}) *Conditions

func (*Conditions) Or

func (this *Conditions) Or(query interface{}, values ...interface{}) *Conditions

func (*Conditions) Prepare

func (this *Conditions) Prepare(cb func(c *Conditions, query interface{}, args []interface{}, replace func(query interface{}, args ...interface{})))

func (*Conditions) Where

func (this *Conditions) Where(query interface{}, values ...interface{}) *Conditions

func (*Conditions) WhereClause

func (this *Conditions) WhereClause(scope *Scope) (result Query)

type DB

type DB struct {
	Val          interface{}
	Error        error
	RowsAffected int64

	Context context.Context

	Query *Query
	// contains filtered or unexported fields
}

DB contains information for current db connection

func CreateFakeDB

func CreateFakeDB(dialect string) (db *DB)

CreateFakeDB create a new fake db with dialect

func FakeDB

func FakeDB(dialect string) (db *DB)

FakeDB get or create a new fake db with dialect

func NewDB

func NewDB(dialect ...Dialector) (db *DB)

func Open

func Open(dialect string, args ...interface{}) (db *DB, err error)

Open initialize a new db connection, need to import driver first, e.g:

import _ "github.com/go-sql-driver/mysql"
func main() {
  db, err := aorm.Open("mysql", "user:password@/dbname?charset=utf8&parseTime=True&loc=Local")
}

AORM has wrapped some drivers, for easier to remember driver's import path, so you could import the mysql driver with

import _ "github.com/moisespsena-go/aorm/dialects/mysql"
// import _ "github.com/moisespsena-go/aorm/dialects/postgres"
// import _ "github.com/moisespsena-go/aorm/dialects/sqlite"
// import _ "github.com/moisespsena-go/aorm/dialects/mssql"

func (*DB) AddError

func (s *DB) AddError(err error) error

AddError add error to the db

func (*DB) AddForeignKey

func (s *DB) AddForeignKey(field string, dest string, onDelete string, onUpdate string) *DB

AddForeignKey Add foreign key to the given scope, e.g:

db.Model(&User{}).AddForeignKey("city_id", "cities(id)", "RESTRICT", "RESTRICT")

func (*DB) AddIndex

func (s *DB) AddIndex(indexName string, columns ...string) *DB

AddIndex add index for columns with given name

func (*DB) AddUniqueIndex

func (s *DB) AddUniqueIndex(indexName string, columns ...string) *DB

AddUniqueIndex add unique index for columns with given name

func (*DB) Assign

func (s *DB) Assign(attrs ...interface{}) *DB

Assigner assign result with argument regardless it is found or not with `FirstOrInit` https://jinzhu.github.io/gorm/crud.html#firstorinit or `FirstOrCreate` https://jinzhu.github.io/gorm/crud.html#firstorcreate

func (*DB) Association

func (s *DB) Association(relatedFieldName string) *Association

Association start `Association Mode` to handler relations things easir in that mode, refer: https://jinzhu.github.io/gorm/associations.html#association-mode

func (*DB) Attrs

func (s *DB) Attrs(attrs ...interface{}) *DB

Attrs initialize struct with argument if record not found with `FirstOrInit` https://jinzhu.github.io/gorm/crud.html#firstorinit or `FirstOrCreate` https://jinzhu.github.io/gorm/crud.html#firstorcreate

func (*DB) AutoInlinePreload

func (s *DB) AutoInlinePreload(value interface{}) *DB

AutoInlinePreload preload associations

func (*DB) AutoMigrate

func (s *DB) AutoMigrate(values ...interface{}) *DB

AutoMigrate run auto migration for given models, will only add missing fields, won'T delete/change current data

func (*DB) Begin

func (s *DB) Begin() *DB

Begin begin a transaction

func (*DB) BlockGlobalUpdate

func (s *DB) BlockGlobalUpdate(enable bool) *DB

BlockGlobalUpdate if true, generates an error on update/delete without where clause. This is to prevent eventual error with empty objects updates/deletions

func (*DB) Callback

func (s *DB) Callback() *Callback

Callback return `Callbacks` container, you could add/change/delete callbacks with it

db.Callback().Create().Register("update_created_at", updateCreated)

Refer https://jinzhu.github.io/gorm/development.html#callbacks

func (*DB) Close

func (s *DB) Close() error

Close close current db connection. If database connection is not an io.Closer, returns an error.

func (*DB) ColumnsScannerCallback

func (s *DB) ColumnsScannerCallback(cb func(scope *Scope, record interface{}, columns []string, values []interface{})) *DB

func (*DB) Commit

func (s *DB) Commit() *DB

Commit commit a transaction

func (*DB) CommonDB

func (s *DB) CommonDB() SQLCommon

CommonDB return the underlying `*sql.DB` or `*sql.Tx` instance, mainly intended to allow coexistence with legacy non-AORM code.

func (*DB) Count

func (s *DB) Count(value interface{}) *DB

Count get how many records for a model

func (*DB) Create

func (s *DB) Create(value interface{}) *DB

Create insert the value into database

func (*DB) CreateTable

func (s *DB) CreateTable(models ...interface{}) *DB

CreateTable create table for models

func (*DB) DB

func (s *DB) DB() *sql.DB

DB get `*sql.DB` from current connection If the underlying database connection is not a *sql.DB, returns nil

func (*DB) Deadline

func (s *DB) Deadline() (deadline time.Time, ok bool)

func (*DB) Debug

func (s *DB) Debug() *DB

Debug start debug mode

func (*DB) DefaultColumnValue

func (s *DB) DefaultColumnValue(valuer func(scope *Scope, record interface{}, column string) interface{}) *DB

func (*DB) Delete

func (s *DB) Delete(value interface{}, where ...interface{}) *DB

Delete delete value match given conditions, if the value has primary key, then will including the primary key as condition

func (*DB) Dialect

func (s *DB) Dialect() Dialector

Dialector get dialect

func (*DB) DisableAfterScanCallback

func (s *DB) DisableAfterScanCallback(typs ...interface{}) *DB

Disable after scan callback. If typs not is empty, disable for typs, other else, disable for all

func (*DB) Done

func (s *DB) Done() <-chan struct{}

func (*DB) DropColumn

func (s *DB) DropColumn(column string) *DB

DropColumn drop a column

func (*DB) DropTable

func (s *DB) DropTable(values ...interface{}) *DB

DropTable drop table for models

func (*DB) DropTableIfExists

func (s *DB) DropTableIfExists(values ...interface{}) *DB

DropTableIfExists drop table if it is exist

func (*DB) DryRun

func (s *DB) DryRun() *DB

DryRun perform a trial run with no changes

func (*DB) EnableAfterScanCallback

func (s *DB) EnableAfterScanCallback(typs ...interface{}) *DB

Enable after scan callback. If typs not is empty, enable for typs, other else, enable for all. The disabled types will not be enabled unless they are specifically informed.

func (*DB) Err

func (s *DB) Err() error

func (*DB) Exec

func (s *DB) Exec(sql string, values ...interface{}) *DB

Exec execute raw sql

func (*DB) Exists

func (s *DB) Exists(where ...interface{}) (ok bool, err error)

Exists used to query single column from a first model result as a map

var createAt time.Time
db.Model(&User{}).Exists()

func (*DB) ExistsValue

func (s *DB) ExistsValue(value interface{}, where ...interface{}) (ok bool, err error)

ExistsValue used to query single column from a first model result as a map

var createAt time.Time
db.ExistsValue(&User{Name:"user name"})

func (*DB) ExtraSelect

func (s *DB) ExtraSelect(key string, values []interface{}, query interface{}, args ...interface{}) *DB

ExtraSelect specify extra fields that you want to retrieve from database when querying

func (*DB) ExtraSelectCallback

func (s *DB) ExtraSelectCallback(f ...func(recorde interface{}, data map[string]*ExtraResult)) *DB

ExtraSelectCalback specify extra select callbacks that you want to retrieve from database when querying

func (*DB) ExtraSelectFields

func (s *DB) ExtraSelectFields(key string, value interface{}, names []string, callback func(scope *Scope, record interface{}), query interface{}, args ...interface{}) *DB

ExtraSelectFields specify extra fields that you want to retrieve from database when querying

func (*DB) ExtraSelectFieldsSetter

func (s *DB) ExtraSelectFieldsSetter(key string, setter ExtraSelectFieldsSetter, structFields []*StructField, query interface{}, args ...interface{}) *DB

ExtraSelectFieldsSetter specify extra fields that you want to retrieve from database when querying

func (*DB) Find

func (s *DB) Find(out interface{}, where ...interface{}) *DB

Find find records that match given conditions

func (*DB) First

func (s *DB) First(out interface{}, where ...interface{}) *DB

First find first record that match given conditions, order by primary key

func (*DB) FirstOrCreate

func (s *DB) FirstOrCreate(out interface{}, where ...interface{}) *DB

FirstOrCreate find first matched record or create a new one with given conditions (only works with struct, map conditions) https://jinzhu.github.io/gorm/crud.html#firstorcreate

func (*DB) FirstOrInit

func (s *DB) FirstOrInit(out interface{}, where ...interface{}) *DB

FirstOrInit find first matched record or initialize a new one with given conditions (only works with struct, map conditions) https://jinzhu.github.io/gorm/crud.html#firstorinit

func (*DB) Get

func (s *DB) Get(name string) (value interface{}, ok bool)

Get get setting by name

func (*DB) GetArgVariabler

func (s *DB) GetArgVariabler(arg interface{}) (argVar ArgBinder)

func (*DB) GetAssigner

func (s *DB) GetAssigner(typ reflect.Type) (assigner Assigner)

func (*DB) GetCurrentUser

func (s *DB) GetCurrentUser() (user interface{}, ok bool)

func (*DB) GetCurrentUserID

func (s *DB) GetCurrentUserID() (id interface{})

func (*DB) GetErrors

func (s *DB) GetErrors() []error

GetErrors get happened errors from the db

func (*DB) Group

func (s *DB) Group(query string) *DB

Group specify the group method on the find

func (*DB) HasBlockGlobalUpdate

func (s *DB) HasBlockGlobalUpdate() bool

HasBlockGlobalUpdate return state of block

func (*DB) HasOrder

func (s *DB) HasOrder() bool

HasOrder returns if order has be specified

func (*DB) HasTable

func (s *DB) HasTable(value interface{}) bool

HasTable check has table or not

func (*DB) Having

func (s *DB) Having(query interface{}, values ...interface{}) *DB

Having specify HAVING conditions for GROUP BY

func (*DB) InlinePreload

func (s *DB) InlinePreload(column string, options ...*InlinePreloadOptions) *DB

Preload preload associations with given conditions

db.Preload("Orders", "state NOT IN (?)", "cancelled").Find(&users)

func (*DB) InlinePreloadFields

func (s *DB) InlinePreloadFields(value interface{}, fields ...string) *DB

InlinePreloadFields set inline preload fields of value type

func (*DB) Inside

func (s *DB) Inside(name ...interface{}) *DB

func (*DB) InstantSet

func (s *DB) InstantSet(name string, value interface{}) *DB

InstantSet instant set setting, will affect current db

func (*DB) IsEnabledAfterScanCallback

func (s *DB) IsEnabledAfterScanCallback(typs ...interface{}) (ok bool)

Return if after scan callbacks has be enable. If typs is empty, return default, other else, return for informed typs.

func (*DB) Join

func (s *DB) Join(fieldName, mode string, handler func()) *DB

Join specify Join field conditions

db.Model(&User{}).Join("INNER", "Email")
// INNER JOIN emails ON emails.user_id = user.id

func (*DB) Joins

func (s *DB) Joins(query string, args ...interface{}) *DB

Joins specify Joins conditions

db.Joins("JOIN emails ON emails.user_id = users.id AND emails.email = ?", "jinzhu@example.org").Find(&user)

func (*DB) Last

func (s *DB) Last(out interface{}, where ...interface{}) *DB

Last find last record that match given conditions, order by primary key

func (*DB) Limit

func (s *DB) Limit(limit interface{}) *DB

Limit specify the number of records to be retrieved

func (*DB) LogMode

func (s *DB) LogMode(enable bool) *DB

LogMode set log mode, `true` for detailed logs, `false` for no log, default, will only print error logs

func (*DB) Loggers

func (s *DB) Loggers(tableName string, set ...bool) (clone *DB, sl *ScopeLoggers, ok bool)

func (*DB) Model

func (s *DB) Model(value interface{}) *DB

Model specify the model you would like to run db operations

// update all users's name to `hello`
db.Model(&User{}).Update("name", "hello")
// if user's primary key is non-blank, will use it as condition, then will only update the user's name to `hello`
db.Model(&user).Update("name", "hello")

func (*DB) ModelStructStorage

func (s *DB) ModelStructStorage() *ModelStructStorage

ModelStructStorage get the model struct storage fom DB

func (*DB) ModifyColumn

func (s *DB) ModifyColumn(column string, typ string) *DB

ModifyColumn modify column to type

func (*DB) New

func (s *DB) New() *DB

New clone a new db connection without search conditions

func (*DB) NewScope

func (s *DB) NewScope(value interface{}) *Scope

NewScope create a scope for current operation

func (*DB) Not

func (s *DB) Not(query interface{}, args ...interface{}) *DB

Not filter records that don'T match current conditions, similar to `Where`

func (*DB) Offset

func (s *DB) Offset(offset interface{}) *DB

Offset specify the number of records to skip before starting to return the records

func (*DB) Omit

func (s *DB) Omit(columns ...string) *DB

Omit specify fields that you want to ignore when saving to database for creating, updating

func (*DB) Or

func (s *DB) Or(query interface{}, args ...interface{}) *DB

Or filter records that match before conditions or this one, similar to `Where`

func (*DB) Order

func (s *DB) Order(value interface{}, reorder ...bool) *DB

Order specify order when retrieve records from database, set reorder to `true` to overwrite defined conditions

db.Order("name DESC")
db.Order("name DESC", true) // reorder
db.Order(aorm.Expr("name = ? DESC", "first")) // sql expression

func (*DB) Path

func (s *DB) Path() []interface{}

func (*DB) PathString

func (s *DB) PathString() string

func (*DB) Pluck

func (s *DB) Pluck(column string, value interface{}) *DB

Pluck used to query single column from a model as a map

var ages []int64
db.Find(&users).Pluck("age", &ages)

func (*DB) PluckFirst

func (s *DB) PluckFirst(column string, value interface{}) *DB

PluckFirst used to query single column from a first model result as a map

var createAt time.Time
db.Model(&User{}).Pluck("created_at", &createdAt)

func (*DB) Preload

func (s *DB) Preload(column string, options ...*InlinePreloadOptions) *DB

Preload preload associations with given conditions

db.Preload("Orders", "state NOT IN (?)", "cancelled").Find(&users)

func (*DB) QueryExpr

func (s *DB) QueryExpr() *Query

QueryExpr returns the query as Query object

func (*DB) Raw

func (s *DB) Raw(sql string, values ...interface{}) *DB

Raw use raw sql as conditions, won'T run it unless invoked by other methods

db.Raw("SELECT name, age FROM users WHERE name = ?", 3).Scan(&result)

func (*DB) RawTransaction

func (s *DB) RawTransaction(f func(tx *sql.Tx) (err error)) (err error)

RawTransaction execute func `f` into sql.Tx

func (*DB) RecordNotFound

func (s *DB) RecordNotFound() bool

RecordNotFound check if returning ErrRecordNotFound error

func (*DB) RegisterAssigner

func (s *DB) RegisterAssigner(assigners ...Assigner) *DB

func (*DB) Related

func (s *DB) Related(value interface{}, foreignKeys ...string) *DB

Related get related associations

func (*DB) RemoveForeignKey

func (s *DB) RemoveForeignKey(field string, dest string) *DB

RemoveForeignKey Remove foreign key from the given scope, e.g:

db.Model(&User{}).RemoveForeignKey("city_id", "cities(id)")

func (*DB) RemoveIndex

func (s *DB) RemoveIndex(indexName string) *DB

RemoveIndex remove index with name

func (*DB) Rollback

func (s *DB) Rollback() *DB

Rollback rollback a transaction

func (*DB) Row

func (s *DB) Row() *sql.Row

Row return `*sql.Row` with given conditions

func (*DB) Rows

func (s *DB) Rows() (*sql.Rows, error)

Rows return `*sql.Rows` with given conditions

func (*DB) Save

func (s *DB) Save(value interface{}) *DB

Save update value in database, if the value doesn'T have primary key, will insert it

func (*DB) Scan

func (s *DB) Scan(dest interface{}) *DB

Scan scan value to a struct

func (*DB) ScanRows

func (s *DB) ScanRows(rows *sql.Rows, result interface{}) error

ScanRows scan `*sql.Rows` to give struct

func (*DB) ScopeErrorCallback

func (s *DB) ScopeErrorCallback(cb func(scope *Scope, err error)) *DB

ScopeErrorCallback register error callback for scope

func (*DB) Scopes

func (s *DB) Scopes(funcs ...func(*DB) *DB) *DB

Scopes pass current database connection to arguments `func(*DB) *DB`, which could be used to add conditions dynamically

func AmountGreaterThan1000(db *aorm.DB) *aorm.DB {
    return db.Where("amount > ?", 1000)
}

func OrderStatus(status []string) func (db *aorm.DB) *aorm.DB {
    return func (db *aorm.DB) *aorm.DB {
        return db.Scopes(AmountGreaterThan1000).Where("status in (?)", status)
    }
}

db.Scopes(AmountGreaterThan1000, OrderStatus([]string{"paid", "shipped"})).Find(&orders)

Refer https://jinzhu.github.io/gorm/crud.html#scopes

func (*DB) Select

func (s *DB) Select(query interface{}, args ...interface{}) *DB

Select specify fields that you want to retrieve from database when querying, by default, will select all fields; When creating/updating, specify fields that you want to save to database

func (*DB) Set

func (s *DB) Set(name string, value interface{}) *DB

Set set setting by name, which could be used in callbacks, will clone a new db, and update its setting

func (*DB) SetCommonDB

func (s *DB) SetCommonDB(db SQLCommon) *DB

SetCommonDB set the underlying `*sql.DB` or `*sql.Tx` instance, mainly intended to allow coexistence with legacy non-AORM code.

func (*DB) SetCurrentUser

func (s *DB) SetCurrentUser(user interface{}) *DB

func (*DB) SetJoinTableHandler

func (s *DB) SetJoinTableHandler(source interface{}, column string, handler JoinTableHandlerInterface)

SetJoinTableHandler set a model's join table handler for a relation

func (*DB) SetLogger

func (s *DB) SetLogger(log logging.Logger)

SetLogger replace default logger

func (*DB) SetSingleUpdate

func (s *DB) SetSingleUpdate(v bool) *DB

func (*DB) SetTableNameResolver

func (db *DB) SetTableNameResolver(resolver TableNameResolver) *DB

func (*DB) SingleUpdate

func (s *DB) SingleUpdate() bool

func (*DB) SingularTable

func (s *DB) SingularTable(enable bool)

SingularTable use singular table by default

func (*DB) StoreBlankField

func (s *DB) StoreBlankField() *DB

StoreBlankField set aorm:store_blank_field as true

func (*DB) StructOf

func (s *DB) StructOf(value ...interface{}) *ModelStruct

StructOf get value's model struct, relationships based on struct and tag definition fom DB

func (*DB) SubQuery

func (s *DB) SubQuery() *Query

SubQuery returns the query as sub query

func (*DB) Table

func (s *DB) Table(name string) *DB

Table specify the table you would like to run db operations

func (*DB) Take

func (s *DB) Take(out interface{}, where ...interface{}) *DB

Take return a record that match given conditions, the order will depend on the database implementation

func (*DB) Transaction

func (s *DB) Transaction(f func(db *DB) (err error)) (err error)

Transaction execute func `f` into transaction

func (*DB) Unscoped

func (s *DB) Unscoped() *DB

Unscoped return all record including deleted record, refer Soft Delete https://jinzhu.github.io/gorm/crud.html#soft-delete

func (*DB) Update

func (s *DB) Update(attrs ...interface{}) *DB

Update update attributes with callbacks, refer: https://jinzhu.github.io/gorm/crud.html#update

func (*DB) UpdateColumn

func (s *DB) UpdateColumn(attrs ...interface{}) *DB

UpdateColumn update attributes without callbacks, refer: https://jinzhu.github.io/gorm/crud.html#update

func (*DB) UpdateColumns

func (s *DB) UpdateColumns(values interface{}) *DB

UpdateColumns update attributes without callbacks, refer: https://jinzhu.github.io/gorm/crud.html#update

func (*DB) Updates

func (s *DB) Updates(values interface{}, ignoreProtectedAttrs ...bool) *DB

Updates update attributes with callbacks, refer: https://jinzhu.github.io/gorm/crud.html#update

func (*DB) Value

func (s *DB) Value(key interface{}) interface{}

func (*DB) Where

func (s *DB) Where(query interface{}, args ...interface{}) *DB

Where return a new relation, filter records with given conditions, accepts `map`, `struct` or `string` as conditions, refer http://jinzhu.github.io/gorm/crud.html#query

type DBNamer

type DBNamer interface {
	DBName() string
}

type DbDataTyper

type DbDataTyper interface {
	AormDataType(dialect Dialector) string
}

type DefaultKeyNamer

type DefaultKeyNamer struct{}

DefaultKeyNamer contains the default foreign key name generator method

func (DefaultKeyNamer) BuildKeyName

func (DefaultKeyNamer) BuildKeyName(kind, tableName string, fields ...string) string

BuildKeyName returns a valid key name (foreign key, index key) for the given table, field and reference

type DefinedID

type DefinedID struct {
	ID bid.BID `aorm:"primary_key"`
}

type Dialector

type Dialector interface {
	Quoter
	KeyNamer

	// Init the dialect
	Init()

	// Cast sql cast's from to
	Cast(from, to string) string

	// GetName get dialect's name
	GetName() string

	// SetDB set db for dialect
	SetDB(db SQLCommon)

	// BindVar return the placeholder for actual values in SQL statements, in many dbs it is "?", Postgres using $1
	BindVar(i int) string

	// DataTypeOf return data's sql type
	DataTypeOf(field *FieldStructure) string

	// HasIndex check has index or not
	HasIndex(tableName string, indexName string) bool
	// HasForeignKey check has foreign key or not
	HasForeignKey(tableName string, foreignKeyName string) bool
	// RemoveIndex remove index
	RemoveIndex(tableName string, indexName string) error
	// HasTable check has table or not
	HasTable(tableName string) bool
	// HasColumn check has column or not
	HasColumn(tableName string, columnName string) bool
	// ModifyColumn modify column's type
	ModifyColumn(tableName string, columnName string, typ string) error

	// LimitAndOffsetSQL return generated SQL with Limit and Offset, as mssql has special case
	LimitAndOffsetSQL(limit, offset interface{}) string
	// SelectFromDummyTable return select values, for most dbs, `SELECT values` just works, mysql needs `SELECT value FROM DUAL`
	SelectFromDummyTable() string
	// LastInsertIdReturningSuffix most dbs support LastInsertId, but postgres needs to use `RETURNING`
	LastInsertIDReturningSuffix(tableName, columnName string) string
	// DefaultValueStr
	DefaultValueStr() string

	// CurrentDatabase return current database name
	CurrentDatabase() string

	Assigners() map[reflect.Type]Assigner
	RegisterAssigner(assigner ...Assigner)
	GetAssigner(typ reflect.Type) (assigner Assigner)
	DuplicateUniqueIndexError(indexes IndexMap, tableName string, sqlErr error) (err error)
}

Dialector interface contains behaviors that differ across SQL database

func GetDialect

func GetDialect(name string) (dialect Dialector, ok bool)

GetDialect gets the dialect for the specified dialect name

func MustGetDialect

func MustGetDialect(name string) (dialect Dialector)

MustGetDialect gets the dialect for the specified dialect name

type DuplicateUniqueIndexError

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

func GetDuplicateUniqueIndexError

func GetDuplicateUniqueIndexError(err ...error) *DuplicateUniqueIndexError

func (DuplicateUniqueIndexError) Cause

func (d DuplicateUniqueIndexError) Cause() error

func (DuplicateUniqueIndexError) Error

func (DuplicateUniqueIndexError) Index

type Errors

type Errors []error

Errors contains all happened errors

func (Errors) Add

func (errs Errors) Add(newErrors ...error) Errors

Add adds an error

func (Errors) Error

func (errs Errors) Error() string

error format happened errors

func (Errors) GetErrors

func (errs Errors) GetErrors() []error

GetErrors gets all happened errors

type ExecState

type ExecState struct {
	Query
	Value interface{}
}

type ExtraResult

type ExtraResult struct {
	Select *extraSelect
	Values []interface{}
	Names  []string
	Map    map[string]int
}

func (*ExtraResult) Get

func (er *ExtraResult) Get(name string) (v interface{}, ok bool)

type ExtraSelectFieldsSetter

type ExtraSelectFieldsSetter func(result interface{}, values []interface{}, set func(result interface{}, low, hight int) interface{})

type ExtraSelectInterface

type ExtraSelectInterface interface {
	SetAormExtraScannedValues(extra map[string]*ExtraResult)
	GetAormExtraScannedValue(name string) (result *ExtraResult, ok bool)
	GetAormExtraScannedValues() map[string]*ExtraResult
}

type ExtraSelectModel

type ExtraSelectModel struct {
	ExtraScannedValues map[string]*ExtraResult `sql:"-"`
}

func (*ExtraSelectModel) GetAormExtraScannedValue

func (es *ExtraSelectModel) GetAormExtraScannedValue(name string) (result *ExtraResult, ok bool)

func (*ExtraSelectModel) GetAormExtraScannedValues

func (es *ExtraSelectModel) GetAormExtraScannedValues() map[string]*ExtraResult

func (*ExtraSelectModel) SetAormExtraScannedValues

func (es *ExtraSelectModel) SetAormExtraScannedValues(extra map[string]*ExtraResult)

type Field

type Field struct {
	*StructField
	IsBlank bool
	Field   reflect.Value
	// contains filtered or unexported fields
}

Field model field definition

func PrimaryFieldsOf

func PrimaryFieldsOf(value interface{}) []*Field

PrimaryFieldsOf get the primary fields instance of value

func (*Field) CallMethodCallback

func (this *Field) CallMethodCallback(name string, object reflect.Value, in ...reflect.Value)

Call the method callback

func (*Field) CallMethodCallbackArgs

func (this *Field) CallMethodCallbackArgs(name string, object reflect.Value, in []reflect.Value)

func (*Field) ID

func (this *Field) ID() (IDValuer, error)

func (*Field) Scaner

func (this *Field) Scaner(dialect Dialector) Scanner

func (*Field) Set

func (this *Field) Set(value interface{}) (err error)

Set set a value to the field

type FieldAssigner

type FieldAssigner interface {
	AormAssigner() Assigner
}

type FieldSelectWraper

type FieldSelectWraper interface {
	SelectWrap(field *StructField, scope *Scope, expr string) Query
}

type FieldSelector

type FieldSelector interface {
	Select(field *StructField, scope *Scope, table string) Query
}

func NewFieldSelector

func NewFieldSelector(selectorFunc FieldSelectorFunc) FieldSelector

type FieldSelectorFunc

type FieldSelectorFunc = func(field *StructField, scope *Scope, expr string) Query

type FieldStructure

type FieldStructure struct {
	Type         reflect.Type
	TagSettings  map[string]string
	Assigner     Assigner
	IsPrimaryKey bool
}

type FieldTypeTagSettinger

type FieldTypeTagSettinger interface {
	TagSetting(field reflect.StructField) TagSetting
}

type FieldsForCreateAcceptor

type FieldsForCreateAcceptor interface {
	AormAcceptFieldsForCreate(scope *Scope) (fields []string, apply bool)
}

type FieldsForCreateExcluder

type FieldsForCreateExcluder interface {
	AormExcludeFieldsForCreate(scope *Scope) (fields []string, apply bool)
}

type FieldsForUpdateAcceptor

type FieldsForUpdateAcceptor interface {
	AormAcceptFieldsForUpdate(scope *Scope) (fields []string, apply bool)
}

type FieldsForUpdateExcluder

type FieldsForUpdateExcluder interface {
	AormExcludeFieldsForUpdate(scope *Scope) (fields []string, apply bool)
}

type Generator

type Generator interface {
	Zeroer
	Generate()
}

type ID

type ID interface {
	Zeroer
	WhereClauser
	fmt.Stringer
	Bytes() []byte
	Fields() []*StructField
	Field() *StructField
	Values() []IDValuer
	Value() IDValuer
	Raw() interface{}
	SetValue(value ...interface{}) (ID, error)
	SetTo(recorde interface{}) interface{}
	Exclude() ID
}

func FakeID

func FakeID(v string) ID

func IDSlice

func IDSlice(args ...interface{}) (r []ID)

func IdOf

func IdOf(value interface{}) ID

IdOf get ID of model value

type IDSlicer

type IDSlicer interface {
	Values() []ID
	Exclude() IDSlicer
}

type IDValueRawConverter

type IDValueRawConverter interface {
	FromRaw(raw interface{}) IDValuer
	ToRaw(value IDValuer) interface{}
}

func IDValueRawConverterGet

func IDValueRawConverterGet(typ reflect.Type) (converter IDValueRawConverter)

type IDValuer

type IDValuer interface {
	Bytes() []byte
	fmt.Stringer
	Zeroer
	Raw() interface{}
	ParseString(s string) (value IDValuer, err error)
	ParseBytes(s []byte) (value IDValuer, err error)
}

type Id

type Id struct {
	TableName string
	// contains filtered or unexported fields
}

func NewId

func NewId(fields []*StructField, values []IDValuer) *Id

func (Id) Bytes

func (this Id) Bytes() (b []byte)

func (Id) Exclude

func (this Id) Exclude() ID

func (Id) Field

func (this Id) Field() *StructField

func (Id) Fields

func (this Id) Fields() []*StructField

func (Id) IsZero

func (this Id) IsZero() bool

func (Id) Raw

func (this Id) Raw() interface{}

func (Id) SetTo

func (this Id) SetTo(recorde interface{}) interface{}

func (Id) SetValue

func (this Id) SetValue(value ...interface{}) (_ ID, err error)

func (Id) String

func (this Id) String() string

func (Id) Value

func (this Id) Value() IDValuer

func (Id) Values

func (this Id) Values() []IDValuer

func (Id) WhereClause

func (this Id) WhereClause(scope *Scope) (result Query)

type IndexMap

type IndexMap map[string]*StructIndex

func (IndexMap) FromColumns

func (this IndexMap) FromColumns(columns ...string) (ix *StructIndex)

FromColumns return index from db column names

func (IndexMap) FromDbName

func (this IndexMap) FromDbName(namer KeyNamer, tableName, indexDbName string) (ix *StructIndex)

FromDbName return index from db name

type InlinePreloadBuilder

type InlinePreloadBuilder struct {
	*Conditions
	*InlinePreloadInfo
}

type InlinePreloadFields

type InlinePreloadFields interface {
	GetAormInlinePreloadFields() []string
}

type InlinePreloadFieldsWithScope

type InlinePreloadFieldsWithScope interface {
	GetAormInlinePreloadFields(scope *Scope) []string
}

type InlinePreloadInfo

type InlinePreloadInfo struct {
	RootScope, ParentScope, Scope *Scope
	Preloader                     *InlinePreloader
	Conditions                    *Conditions
}

type InlinePreloadOptions

type InlinePreloadOptions struct {
	Conditions
	RelatedConditions []interface{}
	Select            []interface{}
	Join              JoinType
	Prepare           func(builder *InlinePreloadBuilder)
}

type InlinePreloader

type InlinePreloader struct {
	RootScope,
	Scope,
	ParentScope *Scope
	DB             *DB
	ID             string
	Field          *StructField
	VirtualField   *VirtualField
	Index          [][]int
	RelationFields []*StructField
	StructFields   []*StructField
	Query          string
}

func (*InlinePreloader) Apply

func (p *InlinePreloader) Apply()

func (*InlinePreloader) Fields

func (p *InlinePreloader) Fields(fields ...interface{})

func (*InlinePreloader) GetFields

func (p *InlinePreloader) GetFields() []*StructField

func (*InlinePreloader) GetQuery

func (p *InlinePreloader) GetQuery() string

func (*InlinePreloader) Scan

func (p *InlinePreloader) Scan(result interface{}, values []interface{}, set func(result interface{}, low, hight int) interface{})

type InlinePreloads

type InlinePreloads struct {
	Count uint
	// map of field path -> alias_name
	DBNames map[string]string
}

func (*InlinePreloads) GetDBName

func (c *InlinePreloads) GetDBName(path string) (dbName string, ok bool)

func (*InlinePreloads) Next

func (c *InlinePreloads) Next(fieldPath ...string) string

type InlineQueries

type InlineQueries []*WithInlineQuery

func (InlineQueries) Join

func (iq InlineQueries) Join(sep ...string) (result *WithInlineQuery)

type Instance

type Instance struct {
	Struct       *ModelStruct
	ReflectValue reflect.Value
	Value        interface{}
	FieldsMap    map[string]*Field
	Fields       []*Field
	Primary      []*Field
}

func InstanceOf

func InstanceOf(value interface{}, fieldsNames ...string) *Instance

InstanceOf get instance of model value

func (*Instance) FieldByName

func (this *Instance) FieldByName(name string) (field *Field, ok bool)

FieldByName find `aorm.Field` with field name or db name

func (*Instance) ID

func (this *Instance) ID() ID

func (*Instance) MustFieldByName

func (this *Instance) MustFieldByName(name string) (field *Field)

MustFieldByName find `aorm.Field` with field name or db name

func (*Instance) PrimaryField

func (this *Instance) PrimaryField() *Field

PrimaryField return main primary field, if defined more that one primary fields, will return the one having column name `id` or the first one

func (*Instance) RelatedFields

func (this *Instance) RelatedFields() []*Field

type IntId

type IntId int64

func (IntId) Bytes

func (this IntId) Bytes() []byte

func (IntId) Int

func (this IntId) Int() int64

func (IntId) IsZero

func (this IntId) IsZero() bool

func (IntId) ParseBytes

func (this IntId) ParseBytes(b []byte) (IDValuer, error)

func (IntId) ParseString

func (this IntId) ParseString(s string) (_ IDValuer, err error)

func (IntId) Raw

func (this IntId) Raw() interface{}

func (IntId) String

func (this IntId) String() string

type IteratorHeader

type IteratorHeader struct {
	Value interface{}
}

type JoinTableForeignKey

type JoinTableForeignKey struct {
	DBName           string
	AssociationField *StructField
}

JoinTableForeignKey join table foreign key struct

type JoinTableHandler

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

JoinTableHandler default join table handler

func NewJoinTableHandler

func NewJoinTableHandler(tableName string, source JoinTableSource, destination JoinTableSource) *JoinTableHandler

func (JoinTableHandler) Add

func (this JoinTableHandler) Add(handler JoinTableHandlerInterface, db *DB, source interface{}, destination interface{}) (err error)

Add create relationship in join table for source and destination

func (JoinTableHandler) Delete

func (this JoinTableHandler) Delete(handler JoinTableHandlerInterface, db *DB, sources ...interface{}) error

Delete delete relationship in join table for sources

func (*JoinTableHandler) Destination

func (this *JoinTableHandler) Destination() JoinTableSource

func (*JoinTableHandler) DestinationForeignKeys

func (this *JoinTableHandler) DestinationForeignKeys() []JoinTableForeignKey

DestinationForeignKeys return destination foreign keys

func (JoinTableHandler) JoinWith

func (this JoinTableHandler) JoinWith(handler JoinTableHandlerInterface, db *DB, source interface{}) *DB

JoinWith query with `Join` conditions

func (*JoinTableHandler) Setup

func (this *JoinTableHandler) Setup(relationship *Relationship, tableName string, source, destination *ModelStruct)

Setup initialize a default join table handler

func (*JoinTableHandler) Source

func (this *JoinTableHandler) Source() JoinTableSource

func (*JoinTableHandler) SourceForeignKeys

func (this *JoinTableHandler) SourceForeignKeys() []JoinTableForeignKey

SourceForeignKeys return source foreign keys

func (JoinTableHandler) Table

func (this JoinTableHandler) Table(db *DB) string

Table return join table's table name

func (*JoinTableHandler) TableName

func (this *JoinTableHandler) TableName() string

type JoinTableHandlerInterface

type JoinTableHandlerInterface interface {
	TableNamer

	// initialize join table handler
	Setup(relationship *Relationship, tableName string, source, destination *ModelStruct)
	// Table return join table's table name
	Table(db *DB) string
	// Add create relationship in join table for source and destination
	Add(handler JoinTableHandlerInterface, db *DB, source interface{}, destination interface{}) error
	// Delete delete relationship in join table for sources
	Delete(handler JoinTableHandlerInterface, db *DB, sources ...interface{}) error
	// JoinWith query with `Join` conditions
	JoinWith(handler JoinTableHandlerInterface, db *DB, source interface{}) *DB
	// SourceForeignKeys return source foreign keys
	SourceForeignKeys() []JoinTableForeignKey
	// DestinationForeignKeys return destination foreign keys
	DestinationForeignKeys() []JoinTableForeignKey

	Source() JoinTableSource
	Destination() JoinTableSource
}

JoinTableHandlerInterface is an interface for how to handle many2many relations

type JoinTableSource

type JoinTableSource struct {
	ModelStruct *ModelStruct
	ForeignKeys []JoinTableForeignKey
}

JoinTableSource is a struct that contains model type and foreign keys

type JoinType

type JoinType uint
const (
	JoinLeft JoinType = iota
	JoinInner
	JoinRight
)

func (JoinType) IsInner

func (ipo JoinType) IsInner() bool

func (JoinType) IsLeft

func (ipo JoinType) IsLeft() bool

func (JoinType) IsRight

func (ipo JoinType) IsRight() bool

func (JoinType) String

func (ipo JoinType) String() string

type KVStorager

type KVStorager interface {
	Set(key string, value string)
	Get(key string) string
}

type KeyNamer

type KeyNamer interface {
	// BuildKeyName returns a valid key name (foreign key, index key) for the given table, field and reference
	BuildKeyName(kind, tableName string, fields ...string) string
}

func KeyNameBuilderOf

func KeyNameBuilderOf(f KeyNamerFunc) KeyNamer

type KeyNamerFunc

type KeyNamerFunc = func(kind, tableName string, fields ...string) string

type Method

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

func MethodByName

func MethodByName(typ reflect.Type, name string) (m Method)

func (Method) Index

func (m Method) Index() int

func (Method) Name

func (m Method) Name() string

func (Method) ObjectMethod

func (m Method) ObjectMethod(object reflect.Value) reflect.Value

func (Method) Ptr

func (m Method) Ptr() bool

func (Method) TypeMethod

func (m Method) TypeMethod(typ reflect.Type) reflect.Method

func (Method) Valid

func (m Method) Valid() bool

type Model

type Model struct {
	ID bid.BID `aorm:"primary_key;serial"`
}

Model base model definition, including fields `BID`, `CreatedAt`, `UpdatedAt`, `DeletedAt`, which could be embedded in your models

type User struct {
  aorm.Model
}

type ModelStruct

type ModelStruct struct {
	TableNameResolver      func(ctx context.Context, singular bool) (tableName string)
	Value                  interface{}
	PrimaryFields          []*StructField
	Fields                 []*StructField
	RelatedFields          []*StructField
	ReadOnlyFields         []*StructField
	DynamicFieldsByName    map[string]*StructField
	Type                   reflect.Type
	PluralTableName        string
	SingularTableName      string
	FieldsByName           map[string]*StructField
	IgnoredFieldsCount     int
	BeforeRelatedCallbacks []func(fromScope *Scope, toScope *Scope, db *DB, fromField *Field) *DB

	Indexes       IndexMap
	UniqueIndexes IndexMap
	// contains filtered or unexported fields
}

ModelStruct model definition

func StructOf

func StructOf(value interface{}) *ModelStruct

StructOf get value's model struct, relationships based on struct and tag definition for value

func (*ModelStruct) AutoInlinePreload

func (this *ModelStruct) AutoInlinePreload(virtualFieldName ...string)

AutoInlinePreload set default auto inline preload virtual field names

func (*ModelStruct) BeforeRelatedCallback

func (this *ModelStruct) BeforeRelatedCallback(cb ...func(fromScope *Scope, toScope *Scope, db *DB, fromField *Field) *DB)

func (*ModelStruct) CreateFieldByName

func (this *ModelStruct) CreateFieldByName(value interface{}, fieldName string) (field *Field, ok bool)

func (*ModelStruct) DefaultID

func (this *ModelStruct) DefaultID() ID

func (*ModelStruct) FieldByName

func (this *ModelStruct) FieldByName(name string) (field *StructField, ok bool)

FieldByName find `aorm.StructField` with field name or db name

func (*ModelStruct) FieldByPath

func (this *ModelStruct) FieldByPath(pth string) (field *StructField)

FieldByPath return field byte path

func (*ModelStruct) FieldDiscovery

func (this *ModelStruct) FieldDiscovery(pth string) (field *StructField, virtualField *VirtualField)

FieldDiscovery discovery field from name or path

func (*ModelStruct) FirstFieldValue

func (this *ModelStruct) FirstFieldValue(value interface{}, names ...string) (field *Field)

func (*ModelStruct) Fqn

func (this *ModelStruct) Fqn() string

func (*ModelStruct) GetID

func (this *ModelStruct) GetID(record interface{}) ID

func (*ModelStruct) GetVirtualField

func (this *ModelStruct) GetVirtualField(fieldName string) *VirtualField

func (*ModelStruct) HasID

func (this *ModelStruct) HasID() bool

HasID returns if has main primary field

func (*ModelStruct) InstanceOf

func (this *ModelStruct) InstanceOf(value interface{}, fieldsNames ...string) (fields *Instance)

func (*ModelStruct) IsSoftDelete

func (this *ModelStruct) IsSoftDelete() bool

func (*ModelStruct) MustCreateFieldByName

func (this *ModelStruct) MustCreateFieldByName(value interface{}, fieldName string) (field *Field)

func (*ModelStruct) NonIgnoredStructFields

func (this *ModelStruct) NonIgnoredStructFields() []*StructField

GetNonIgnoredStructFields get non ignored model's field structs

func (*ModelStruct) NonRelatedStructFields

func (this *ModelStruct) NonRelatedStructFields() []*StructField

NonRelatedStructFields get non ignored model's field structs

func (*ModelStruct) NormalStructFields

func (this *ModelStruct) NormalStructFields() (fields []*StructField)

GetNonIgnoredStructFields get non ignored model's field structs

func (*ModelStruct) ParseIDBytes

func (this *ModelStruct) ParseIDBytes(b []byte) (_ ID, err error)

func (*ModelStruct) ParseIDString

func (this *ModelStruct) ParseIDString(s string) (_ ID, err error)

func (*ModelStruct) PrimaryField

func (this *ModelStruct) PrimaryField() *StructField

PrimaryField return main primary field, if defined more that one primary fields, will return the one having column name `id` or the first one

func (*ModelStruct) PrimaryFieldsInstance

func (this *ModelStruct) PrimaryFieldsInstance(value interface{}) (fields []*Field)

func (*ModelStruct) RealTableName

func (this *ModelStruct) RealTableName(ctx context.Context, singular bool) (name string)

RealTableName get real table name

func (*ModelStruct) SetIdFromString

func (this *ModelStruct) SetIdFromString(record interface{}, idstr string) (err error)

func (*ModelStruct) SetVirtualField

func (this *ModelStruct) SetVirtualField(fieldName string, value interface{}) *VirtualField

func (*ModelStruct) TableName

func (this *ModelStruct) TableName(ctx context.Context, singular bool) string

tableName get model's table name

func (*ModelStruct) UniqueIdexesNamesMap

func (this *ModelStruct) UniqueIdexesNamesMap(namer KeyNamer, tableName string) map[string]*StructIndex

UniqueIdexesNamesMap return unique idexes by index name map

type ModelStructStorage

type ModelStructStorage struct {
	ModelStructsMap    *safeModelStructsMap
	TableNameResolvers []TableNameResolver
	GetAssigner        func(typ reflect.Type) Assigner
}

func NewModelStructStorage

func NewModelStructStorage() *ModelStructStorage

func (*ModelStructStorage) GetOrNew

func (this *ModelStructStorage) GetOrNew(value interface{}, callback ...func(modelStruct *ModelStruct)) (modelStruct *ModelStruct, err error)

type ModelTS

type ModelTS struct {
	Model
	Timestamps
}

type ModelWithVirtualFields

type ModelWithVirtualFields interface {
	VirtualFieldsGetter
	VirtualFieldsSetter
}

type OnRelated

type OnRelated interface {
	AormOnRelated(fromScope, scope *Scope, db *DB) *DB
}

type OnRelatedField

type OnRelatedField interface {
	AormOnRelatedField(fromScope, scope *Scope, db *DB, field *Field) *DB
}

type Operation

type Operation string
const (
	OpQuery  Operation = "select"
	OpCreate Operation = "create"
	OpUpdate Operation = "update"
	OpDelete Operation = "delete"
)

type PathError

type PathError interface {
	error
	Path() string
}

type Query

type Query struct {
	Query string
	Args  Vars
}

func Expr

func Expr(expression string, args ...interface{}) *Query

Expr generate raw SQL expression, for example:

DB.Model(&product).Update("price", aorm.Expr("price * ? + ?", 2, 100))

func (*Query) AddArgs

func (this *Query) AddArgs(arg ...interface{}) *Query

func (Query) Build

func (this Query) Build(appender ToVarsAppender) (query string, err error)

func (Query) String

func (this Query) String() string

func (Query) Wrap

func (this Query) Wrap(prefix, sufix string) Query

type QueryError

type QueryError struct {
	QueryInfo
	// contains filtered or unexported fields
}

Represents Query error

func GetQueryError

func GetQueryError(err ...error) *QueryError

func NewQueryError

func NewQueryError(cause error, q Query, varBinder func(i int) string) *QueryError

func (*QueryError) Cause

func (e *QueryError) Cause() error

Returns the original error

func (*QueryError) Error

func (e *QueryError) Error() string

type QueryInfo

type QueryInfo struct {
	Query
	// contains filtered or unexported fields
}

Represents Query with args Info

func NewQueryInfo

func NewQueryInfo(q Query, varBinder func(i int) string) *QueryInfo

func (*QueryInfo) Args

func (e *QueryInfo) Args() []interface{}

func (*QueryInfo) ArgsName

func (e *QueryInfo) ArgsName() []string

func (*QueryInfo) EachArgs

func (e *QueryInfo) EachArgs(cb func(i int, name string, value interface{}))

func (*QueryInfo) Sql

func (e *QueryInfo) Sql() string

func (*QueryInfo) String

func (e *QueryInfo) String() string

type QuoteRuner

type QuoteRuner rune

func (QuoteRuner) QuoteChar

func (this QuoteRuner) QuoteChar() rune

type Quoter

type Quoter interface {
	// DefaultQuoter quotes char for field name to avoid SQL parsing exceptions by using a reserved word as a field name
	QuoteChar() rune
}

type RecordsIterator

type RecordsIterator interface {
	Start() (state interface{}, err error)
	Done(state interface{}) (ok bool)
	Next(state interface{}) (recorde, newState interface{}, err error)
}

type RecordsIteratorOpener

type RecordsIteratorOpener interface {
	Open() (header interface{}, it RecordsIterator, err error)
}

type Relationship

type Relationship struct {
	Model, AssociationModel      *ModelStruct
	Kind                         string
	FieldName                    string
	PolymorphicType              string
	PolymorphicDBName            string
	PolymorphicValue             func(ctx context.Context, singular bool) string
	ForeignFieldNames            []string
	ForeignDBNames               []string
	AssociationForeignFieldNames []string
	AssociationForeignDBNames    []string
	JoinTableHandler             JoinTableHandlerInterface
}

Relationship described the relationship between models

func (*Relationship) AssoctiationFields

func (this *Relationship) AssoctiationFields() []*StructField

func (*Relationship) DefaultRelatedID

func (this *Relationship) DefaultRelatedID() (id ID)

func (*Relationship) ForeignFields

func (this *Relationship) ForeignFields() []*StructField

func (*Relationship) GetRelatedID

func (this *Relationship) GetRelatedID(record interface{}) (id ID)

func (*Relationship) InstanceToRelatedID

func (this *Relationship) InstanceToRelatedID(instance *Instance) (id ID)

func (*Relationship) RelatedFields

func (this *Relationship) RelatedFields() []*StructField

func (*Relationship) SetRelatedID

func (this *Relationship) SetRelatedID(record interface{}, id ID)

type Reseter

type Reseter interface {
	Reset()
}

type RowQueryResult

type RowQueryResult struct {
	Row *sql.Row
}

type RowsQueryResult

type RowsQueryResult struct {
	Rows  *sql.Rows
	Error error
}

type SQLCommon

type SQLCommon interface {
	Exec(query string, args ...interface{}) (sql.Result, error)
	Prepare(query string) (*sql.Stmt, error)
	Query(query string, args ...interface{}) (*sql.Rows, error)
	QueryRow(query string, args ...interface{}) *sql.Row
}

SQLCommon is the minimal database connection functionality gorm requires. Implemented by *sql.DB.

type SQLSizer

type SQLSizer interface {
	SQLSize(dialect Dialector) int
}

type SafeNameBuilder

type SafeNameBuilder struct {
	Cache             KVStorager
	PreFormat, Format func(v string) string
}

func NewSafeNameBuilder

func NewSafeNameBuilder(cache KVStorager, format ...func(v string) string) *SafeNameBuilder

func (*SafeNameBuilder) Build

func (this *SafeNameBuilder) Build(name string) string

func (*SafeNameBuilder) BuildParts

func (this *SafeNameBuilder) BuildParts(name string, sep string) string

type Scanner

type Scanner = sql.Scanner

func ScannerFunc

func ScannerFunc(f func(src interface{}) error) Scanner

type Scope

type Scope struct {
	Query
	Search *search
	Value  interface{}

	ExecTime time.Time

	Operation Operation
	// contains filtered or unexported fields
}

Scope contain current operation's information when you perform any operation on the database

func (*Scope) AddToVars

func (scope *Scope) AddToVars(value interface{}) (replacement string)

AddToVars add value as sql's vars, used to prevent SQL injection

func (*Scope) AutoInlinePreload

func (s *Scope) AutoInlinePreload() *Scope

AutoInlinePreload preload associations

func (*Scope) Begin

func (scope *Scope) Begin() *Scope

Begin start a transaction

func (*Scope) CallMethod

func (scope *Scope) CallMethod(methodName string)

CallMethod call scope value's Method, if it is a slice, will call its element's Method one by one

func (*Scope) Clause

func (scope *Scope) Clause(clause interface{}) string

func (*Scope) ClauseToSql

func (scope *Scope) ClauseToSql(clause interface{}) (string, bool)

func (*Scope) CombinedConditionSql

func (scope *Scope) CombinedConditionSql() string

CombinedConditionSql return combined condition sql

func (*Scope) CommitOrRollback

func (scope *Scope) CommitOrRollback() *Scope

CommitOrRollback commit current transaction if no error happened, otherwise will rollback it

func (*Scope) Context

func (scope *Scope) Context() context.Context

func (*Scope) DB

func (scope *Scope) DB() *DB

DB return scope's DB connection

func (*Scope) Dialect

func (scope *Scope) Dialect() Dialector

Dialector get dialect

func (*Scope) Err

func (scope *Scope) Err(err error) error

Err add error to Scope

func (*Scope) Error

func (scope *Scope) Error() error

error return error

func (*Scope) ErrorCallbacks

func (s *Scope) ErrorCallbacks() (callbacks []func(scope *Scope, err error))

func (*Scope) Exec

func (scope *Scope) Exec() *Scope

Exec perform generated SQL

func (*Scope) ExecResult

func (scope *Scope) ExecResult() sql.Result

ExecResult perform generated SQL and return result

func (*Scope) FieldByName

func (scope *Scope) FieldByName(name string) (field *Field, ok bool)

CreateFieldByName find `aorm.Field` with field name or db name

func (*Scope) Get

func (scope *Scope) Get(name string) (interface{}, bool)

Get get setting by name

func (*Scope) GetBool

func (scope *Scope) GetBool(name string, defaul ...bool) bool

GetBool get boolean setting by name ou default

func (*Scope) GetCurrentUserID

func (scope *Scope) GetCurrentUserID() (id interface{})

func (*Scope) GetNonIgnoredStructFields

func (scope *Scope) GetNonIgnoredStructFields() []*StructField

GetNonIgnoredStructFields get non ignored model's field structs

func (*Scope) GetNonRelatedStructFields

func (scope *Scope) GetNonRelatedStructFields() []*StructField

GetNonIgnoredStructFields get non ignored model's field structs

func (*Scope) GetStructFields

func (scope *Scope) GetStructFields() (fields []*StructField)

GetStructFields get model's field structs

func (*Scope) GetVirtualField

func (s *Scope) GetVirtualField(fieldName string) *VirtualField

func (*Scope) HasColumn

func (scope *Scope) HasColumn(column string) bool

HasColumn to check if has column

func (*Scope) HasError

func (scope *Scope) HasError() bool

HasError check if there are any error

func (*Scope) HasPrimaryFields

func (scope *Scope) HasPrimaryFields() (ok bool)

HasPrimaryFields return if scope's has primary fields

func (*Scope) ID

func (scope *Scope) ID() ID

ID get value's id

func (*Scope) IndirectValue

func (scope *Scope) IndirectValue() reflect.Value

IndirectValue return scope's reflect value's indirect value

func (*Scope) InlinePreloadFields

func (s *Scope) InlinePreloadFields(value interface{}, fields ...string) *Scope

InlinePreloadFields set inline preload fields of value type

func (*Scope) InlinePreloads

func (scope *Scope) InlinePreloads() *InlinePreloads

func (*Scope) Instance

func (scope *Scope) Instance() *Instance

Instance get value's instance

func (*Scope) InstanceGet

func (scope *Scope) InstanceGet(name string) (interface{}, bool)

InstanceGet get instance setting from current operation

func (*Scope) InstanceGetBool

func (scope *Scope) InstanceGetBool(name string, defaul ...bool) bool

InstanceGetBool get boolean instance setting from current operation

func (*Scope) InstanceID

func (scope *Scope) InstanceID() string

InstanceID get InstanceID for scope

func (*Scope) InstanceSet

func (scope *Scope) InstanceSet(name string, value interface{}) *Scope

InstanceSet set instance setting for current operation, but not for operations in callbacks, like saving associations callback

func (*Scope) Log

func (scope *Scope) Log(v ...interface{})

Log print log message

func (*Scope) Loggers

func (s *Scope) Loggers(set ...bool) (sl *ScopeLoggers, ok bool)

func (*Scope) MustFieldByName

func (scope *Scope) MustFieldByName(name string) (field *Field)

MustFieldByName find `aorm.Field` with field name or db name

func (*Scope) MustLoggers

func (s *Scope) MustLoggers(set ...bool) (sl *ScopeLoggers)

func (*Scope) New

func (scope *Scope) New(value interface{}) *Scope

New create a new Scope without search information

func (*Scope) NewDB

func (scope *Scope) NewDB() *DB

NewDB create a new DB without search information

func (*Scope) OmitAttrs

func (scope *Scope) OmitAttrs() []string

OmitAttrs return omitted attributes

func (*Scope) PrimaryField

func (scope *Scope) PrimaryField() *Field

PrimaryField return scope's main primary field, if defined more that one primary fields, will return the one having column name `id` or the first one

func (*Scope) PrimaryFields

func (scope *Scope) PrimaryFields() (fields []*Field)

PrimaryFields return scope's primary fields

func (*Scope) PrimaryKey

func (scope *Scope) PrimaryKey() interface{}

PrimaryKey get the primary key's value

func (*Scope) PrimaryKeyDbName

func (scope *Scope) PrimaryKeyDbName() string

PrimaryKeyDbName get main primary field's db name

func (*Scope) PrimaryKeyZero

func (scope *Scope) PrimaryKeyZero() bool

PrimaryKeyZero check main primary field's value is blank or not

func (*Scope) Quote

func (scope *Scope) Quote(str string) string

Quote used to quote string to escape them for database

func (*Scope) QuotedTableName

func (scope *Scope) QuotedTableName() (name string)

QuotedTableName return quoted table name

func (*Scope) Raw

func (scope *Scope) Raw(sql string) *Scope

Raw set raw sql

func (*Scope) RealTableName

func (scope *Scope) RealTableName() (name string)

tableName return table name

func (*Scope) ResultSender

func (scope *Scope) ResultSender() (dest reflect.Value, send func(el reflect.Value))

ResultSender return scope's value's result sender

func (*Scope) SQLDB

func (scope *Scope) SQLDB() SQLCommon

SQLDB return *sql.DB

func (*Scope) ScopeOfField

func (scope *Scope) ScopeOfField(fieldName string) *Scope

func (*Scope) SelectAttrs

func (scope *Scope) SelectAttrs() []string

SelectAttrs return selected attributes

func (*Scope) Set

func (scope *Scope) Set(name string, value interface{}) *Scope

Set set value by name

func (*Scope) SetColumn

func (scope *Scope) SetColumn(column interface{}, value interface{}) error

SetColumn to set the column's value, column could be field or field's name/dbname

func (*Scope) SetVirtualField

func (s *Scope) SetVirtualField(fieldName string, value interface{}, options ...map[interface{}]interface{}) (vf *VirtualField)

func (*Scope) SkipLeft

func (scope *Scope) SkipLeft()

SkipLeft skip remaining callbacks

func (*Scope) Struct

func (scope *Scope) Struct() *ModelStruct

Struct get value's model struct, relationships based on struct and tag definition

func (*Scope) StructOf

func (scope *Scope) StructOf(value interface{}) *ModelStruct

StructOf get value's model struct, relationships based on struct and tag definition for value

func (*Scope) TableName

func (scope *Scope) TableName() string

tableName return table name

func (*Scope) ValuesFields

func (scope *Scope) ValuesFields(structFields []*StructField) []*Field

ValuesFields create value's fields from structFields

type ScopeLoggers

type ScopeLoggers struct {
	Async bool
	// contains filtered or unexported fields
}

func (*ScopeLoggers) All

func (s *ScopeLoggers) All(callback func(action string, scope *Scope)) *ScopeLoggers

func (*ScopeLoggers) Call

func (s *ScopeLoggers) Call(action string, scope *Scope)

func (*ScopeLoggers) Create

func (s *ScopeLoggers) Create(callback func(action string, scope *Scope)) *ScopeLoggers

func (*ScopeLoggers) Crud

func (s *ScopeLoggers) Crud(callback func(action string, scope *Scope)) *ScopeLoggers

func (*ScopeLoggers) Delete

func (s *ScopeLoggers) Delete(callback func(action string, scope *Scope)) *ScopeLoggers

func (*ScopeLoggers) Exec

func (s *ScopeLoggers) Exec(callback func(action string, scope *Scope)) *ScopeLoggers

func (*ScopeLoggers) Many

func (s *ScopeLoggers) Many(callback func(action string, scope *Scope), actions ...string) *ScopeLoggers

func (*ScopeLoggers) Query

func (s *ScopeLoggers) Query(callback func(action string, scope *Scope)) *ScopeLoggers

func (*ScopeLoggers) Register

func (s *ScopeLoggers) Register(action string, callback func(action string, scope *Scope)) *ScopeLoggers

func (*ScopeLoggers) Update

func (s *ScopeLoggers) Update(callback func(action string, scope *Scope)) *ScopeLoggers

type Selector

type Selector interface {
	Select(scope *Scope, tableName string) Query
}

type SimpleAssigner

type SimpleAssigner struct {
	ValuerFunc  func(dialect Dialector, value interface{}) driver.Valuer
	ScanerFunc  func(dialect Dialector, dest reflect.Value) Scanner
	Typ         reflect.Type
	SQLtype     string
	SQLtypeFunc func(dialect Dialector) string
}

func (*SimpleAssigner) SQLType

func (assigner *SimpleAssigner) SQLType(dialect Dialector) string

func (*SimpleAssigner) Scaner

func (assigner *SimpleAssigner) Scaner(dialect Dialector, dest reflect.Value) Scanner

func (*SimpleAssigner) Type

func (assigner *SimpleAssigner) Type() reflect.Type

func (*SimpleAssigner) Valuer

func (assigner *SimpleAssigner) Valuer(dialect Dialector, value interface{}) driver.Valuer

type SoftDelete

type SoftDelete struct {
	DeletedAt *time.Time `sql:"index"`
}

func (*SoftDelete) GetDeletedAt

func (d *SoftDelete) GetDeletedAt() *time.Time

type SoftDeleteAudited

type SoftDeleteAudited struct {
	SoftDelete
	DeletedByID bid.BID
}

func (*SoftDeleteAudited) GetDeletedBy

func (a *SoftDeleteAudited) GetDeletedBy() interface{}

func (*SoftDeleteAudited) SetDeletedBy

func (a *SoftDeleteAudited) SetDeletedBy(deletedBy interface{})

type SoftDeleteAuditor

type SoftDeleteAuditor interface {
	SoftDeleter
	SetDeletedBy(deletedBy interface{})
	GetDeletedBy() *string
}

type SoftDeleter

type SoftDeleter interface {
	GetDeletedAt() *time.Time
}

type SqlClauser

type SqlClauser interface {
	SqlClause(scope *Scope) (query string)
}

type StrId

type StrId string

func (StrId) Bytes

func (this StrId) Bytes() []byte

func (StrId) IsZero

func (this StrId) IsZero() bool

func (StrId) ParseBytes

func (StrId) ParseBytes(b []byte) (IDValuer, error)

func (StrId) ParseString

func (StrId) ParseString(s string) (IDValuer, error)

func (StrId) Raw

func (this StrId) Raw() interface{}

func (StrId) String

func (this StrId) String() string

type StringParser

type StringParser interface {
	ParseString(s string) (err error)
}

type Strings

type Strings struct{}

func (Strings) SQLType

func (Strings) SQLType(dialect Dialector) string

func (Strings) Scaner

func (Strings) Scaner(_ Dialector, dest reflect.Value) Scanner

func (Strings) Type

func (Strings) Type() reflect.Type

func (Strings) Valuer

func (Strings) Valuer(_ Dialector, value interface{}) driver.Valuer

type StructField

type StructField struct {
	DBName          string
	Name            string
	Names           []string
	IsPrimaryKey    bool
	IsNormal        bool
	IsIgnored       bool
	IsScanner       bool
	IsReadOnly      bool
	HasDefaultValue bool
	Tag             reflect.StructTag
	TagSettings     TagSetting
	Struct          reflect.StructField
	BaseModel       *ModelStruct
	IsForeignKey    bool
	Relationship    *Relationship
	MethodCallbacks map[string]StructFieldMethodCallback
	StructIndex     []int
	Index           int
	Assigner        Assigner
	Data            map[interface{}]interface{}
	Selector        FieldSelector
	SelectWraper    FieldSelectWraper
}

StructField model field's struct definition

func (*StructField) CallMethodCallback

func (this *StructField) CallMethodCallback(name string, object reflect.Value, in ...reflect.Value)

Call the method callback if exists by name. the

func (*StructField) CallMethodCallbackArgs

func (this *StructField) CallMethodCallbackArgs(name string, object reflect.Value, in []reflect.Value)

Call the method callback if exists by name.

func (StructField) DefaultID

func (this StructField) DefaultID() (IDValuer, error)

func (StructField) IDOf

func (this StructField) IDOf(v interface{}) (IDValuer, error)

func (*StructField) Select

func (this *StructField) Select(scope *Scope, tableName string) Query

func (*StructField) SelectWrap

func (this *StructField) SelectWrap(scope *Scope, expr string) Query

func (*StructField) String

func (this *StructField) String() string

func (*StructField) Structure

func (this *StructField) Structure() *FieldStructure

type StructFieldMethodCallback

type StructFieldMethodCallback struct {
	Method
	Caller reflect.Value
}

func (StructFieldMethodCallback) Call

func (s StructFieldMethodCallback) Call(object reflect.Value, in []reflect.Value)

type StructFieldMethodCallbacksRegistrator

type StructFieldMethodCallbacksRegistrator struct {
	Callbacks  map[string]reflect.Value
	FieldTypes safeEnabledFieldTypes
	// contains filtered or unexported fields
}

func NewStructFieldMethodCallbacksRegistrator

func NewStructFieldMethodCallbacksRegistrator() *StructFieldMethodCallbacksRegistrator

func (*StructFieldMethodCallbacksRegistrator) DisableFieldType

func (registrator *StructFieldMethodCallbacksRegistrator) DisableFieldType(typs ...interface{})

Disable all callbacks for field type

Example
package main

import (
	"fmt"
)

func main() {
	fmt.Println(`if registrator.IsEnabledFieldType(&Media{}) {
	registrator.DisableFieldType(&Media{})
}`)
}
Output:

func (*StructFieldMethodCallbacksRegistrator) EnableFieldType

func (registrator *StructFieldMethodCallbacksRegistrator) EnableFieldType(typs ...interface{})

Enable all callbacks for field type

Example
package main

import (
	"fmt"
)

func main() {
	fmt.Println(`if !registrator.IsEnabledFieldType(&Media{}) {
	registrator.EnableFieldType(&Media{})
}`)
}
Output:

func (*StructFieldMethodCallbacksRegistrator) IsEnabledFieldType

func (registrator *StructFieldMethodCallbacksRegistrator) IsEnabledFieldType(typ interface{}) bool

Return if all callbacks for field type is enabled

func (*StructFieldMethodCallbacksRegistrator) RegisterFieldType

func (registrator *StructFieldMethodCallbacksRegistrator) RegisterFieldType(typs ...interface{})

Register new field type and enable all available callbacks for here

Example
package main

import (
	"fmt"
)

func main() {
	fmt.Println("registrator.RegisterFieldType(&Media{})")
}
Output:

func (*StructFieldMethodCallbacksRegistrator) RegisteredFieldType

func (registrator *StructFieldMethodCallbacksRegistrator) RegisteredFieldType(typ interface{}) bool

Return if field type is registered

Example
package main

import (
	"fmt"
)

func main() {
	fmt.Println(`
if registrator.RegisteredFieldType(&Media{}) {
	println("not registered")
}`)
}
Output:

func (*StructFieldMethodCallbacksRegistrator) UnregisterFieldType

func (registrator *StructFieldMethodCallbacksRegistrator) UnregisterFieldType(typ interface{}) (ok bool)

Unregister field type and return if ok

type StructFieldSetuper

type StructFieldSetuper interface {
	AormStructFieldSetup(model *ModelStruct, field *StructField)
}

type StructIndex

type StructIndex struct {
	Model         *ModelStruct
	Unique        bool
	NameTemplate  string
	Fields        []*StructField
	WhereTemplate string
	Where         string
}

func (*StructIndex) BuildName

func (this *StructIndex) BuildName(d KeyNamer, tableName string) (name string)

func (*StructIndex) Columns

func (this *StructIndex) Columns() []string

func (*StructIndex) FieldsNames

func (this *StructIndex) FieldsNames() []string

func (*StructIndex) SqlCreate

func (this *StructIndex) SqlCreate(d Dialector, tableName string) (sql string)

func (*StructIndex) SqlDrop

func (this *StructIndex) SqlDrop(d interface {
	Quoter
	KeyNamer
}, tableName string) (sql string)

func (*StructIndex) String

func (this *StructIndex) String() (s string)

type TableNamePlurabler

type TableNamePlurabler interface {
	TableName(singular bool) string
}

type TableNameResolver

type TableNameResolver interface {
	TableName(singular bool, value interface{}) (tableName string, ok bool)
}

func TableNameResolverOf

func TableNameResolverOf(f func(singular bool, value interface{}) (tableName string, ok bool)) TableNameResolver

type TableNameResolverFunc

type TableNameResolverFunc func(singular bool, value interface{}) (tableName string, ok bool)

func (TableNameResolverFunc) TableName

func (this TableNameResolverFunc) TableName(singular bool, value interface{}) (tableName string, ok bool)

type TableNamer

type TableNamer interface {
	TableName() string
}

type TagSetting

type TagSetting map[string]string

func (TagSetting) Enable

func (this TagSetting) Enable(key string)

func (TagSetting) Flag

func (this TagSetting) Flag(name string) bool

func (TagSetting) Set

func (this TagSetting) Set(key, value string)

func (TagSetting) Update

func (this TagSetting) Update(setting ...map[string]string)

type Timestamper

type Timestamper interface {
	GetCreatedAt() time.Time
	GetUpdatedAt() time.Time
}

type Timestamps

type Timestamps struct {
	CreatedAt time.Time
	UpdatedAt time.Time
}

func (*Timestamps) GetCreatedAt

func (t *Timestamps) GetCreatedAt() time.Time

func (*Timestamps) GetUpdatedAt

func (t *Timestamps) GetUpdatedAt() time.Time

type ToVarsAppender

type ToVarsAppender interface {
	AddToVars(value interface{}) (replacement string)
}

type UintId

type UintId uint64

func (UintId) Bytes

func (this UintId) Bytes() []byte

func (UintId) IsZero

func (this UintId) IsZero() bool

func (UintId) ParseBytes

func (UintId) ParseBytes(b []byte) (IDValuer, error)

func (UintId) ParseString

func (UintId) ParseString(s string) (_ IDValuer, err error)

func (UintId) Raw

func (this UintId) Raw() interface{}

func (UintId) String

func (this UintId) String() string

func (UintId) Uint

func (this UintId) Uint() uint64

type ValueScanner

type ValueScanner struct {
	Field   *Field
	Typ     reflect.Type
	Data    interface{}
	NotNil  bool
	IsValid bool
	Ptr     bool
	Set     func(f *ValueScanner)
	MakePtr func() interface{}
}

func NewFieldScanner

func NewFieldScanner(field *Field) *ValueScanner

func NewValueScanner

func NewValueScanner(typ reflect.Type) *ValueScanner

func (*ValueScanner) IsNil

func (f *ValueScanner) IsNil() bool

func (*ValueScanner) IsPtr

func (f *ValueScanner) IsPtr() bool

func (*ValueScanner) Scan

func (f *ValueScanner) Scan(src interface{}) error

type Vars

type Vars []interface{}

type VirtualField

type VirtualField struct {
	ModelStruct          *ModelStruct
	FieldName            string
	StructIndex          int
	Value                interface{}
	Options              map[interface{}]interface{}
	Setter               func(vf *VirtualField, recorde, value interface{})
	Getter               func(vf *VirtualField, recorde interface{}) (value interface{}, ok bool)
	LocalFieldName       string
	InlinePreloadOptions InlinePreloadOptions
}

func (*VirtualField) Get

func (vf *VirtualField) Get(recorde interface{}) (value interface{}, ok bool)

func (*VirtualField) Set

func (vf *VirtualField) Set(recorde, value interface{})

type VirtualFieldValue

type VirtualFieldValue struct {
	Value interface{}
}

type VirtualFields

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

func (*VirtualFields) GetVirtualField

func (m *VirtualFields) GetVirtualField(fieldName string) (value interface{}, ok bool)

func (*VirtualFields) SetVirtualField

func (m *VirtualFields) SetVirtualField(fieldName string, value interface{})

type VirtualFieldsGetter

type VirtualFieldsGetter interface {
	GetVirtualField(fieldName string) (value interface{}, ok bool)
}

type VirtualFieldsSetter

type VirtualFieldsSetter interface {
	SetVirtualField(fieldName string, value interface{})
}

type WhereClauser

type WhereClauser interface {
	WhereClause(scope *Scope) (result Query)
}

type WithInlineQuery

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

func IQ

func IQ(query string, args ...interface{}) *WithInlineQuery

func (*WithInlineQuery) Paths

func (iq *WithInlineQuery) Paths() []string

func (*WithInlineQuery) Query

func (iq *WithInlineQuery) Query() string

func (*WithInlineQuery) String

func (iq *WithInlineQuery) String() string

func (*WithInlineQuery) WhereClause

func (iq *WithInlineQuery) WhereClause(scope *Scope) Query

type Zeroer

type Zeroer interface {
	IsZero() bool
}

Source Files

Directories

Path Synopsis
dialects

Jump to

Keyboard shortcuts

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