schema

package
v0.0.0-...-92cf2b6 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2018 License: BSD-2-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DbType

func DbType(f *Field) bool

DbType is a FieldSelector for selecting a Field with a value supported by the database driver.

func Key

func Key(f *Field) bool

Key is a FieldSelector for selecting a primary key.

func NonKey

func NonKey(f *Field) bool

NonKey is a FieldSelector for selecting a non-key field.

func NonNil

func NonNil(f *Field) bool

NonNil is a FieldSelector for selecting a non-nil value.

Types

type Field

type Field struct {
	Name  string
	Value interface{}
	IsKey bool
}

Field represents a field in a record.

func NewField

func NewField(name string, value interface{}, isKey bool) *Field

NewField creates a Field given name, value and whether it is a primary key or not.

type FieldSelector

type FieldSelector func(*Field) bool

FieldSelector is a function that returns a boolean value given a Field, for selecting one or multiple fields.

type Fields

type Fields []*Field

Fields is the slice of Field.

func (Fields) Filter

func (fs Fields) Filter(conds ...FieldSelector) (fields Fields)

Filter method filters the Fields according to some FieldSelectors and returns the result.

func (Fields) Values

func (fs Fields) Values() []interface{}

Values returns a slice of field values.

type Record

type Record struct {
	Name   string // Name of the table
	Fields Fields // Fields in the table
}

Record represents a table record including the table name.

func NewRecord

func NewRecord(s interface{}) *Record

NewRecord creates a Record from an object.

func (*Record) SetKey

func (r *Record) SetKey(names ...string) *Record

SetKey sets the primary keys of a record.

Jump to

Keyboard shortcuts

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