Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultSchema = NewSchema()
DefaultSchema initializes a common Schema.
View Source
var DefaultTag = "db"
DefaultTag is the default struct field tag.
Functions ¶
Types ¶
type Column ¶
Column holds the database column name and other properties extracted by a struct's field.
type ColumnNameFunc ¶
ColumnNameFunc is the function which converts a struct field name to a database column name.
type Row ¶
type Row struct { Schema string // e.g. public Name string // e.g. users. Must set to a custom one if the select query contains AS names. StructType reflect.Type Columns map[string]*Column // e.g. "id":{"id", 0, [0]} }
Row holds the column definitions and the struct type & name.
type Schema ¶
type Schema struct { Name string Rows map[reflect.Type]*Row ColumnNameFunc ColumnNameFunc AutoCloseRows bool }
Schema holds the row definitions.
func NewSchema ¶
func NewSchema() *Schema
NewSchema returns a new Schema. Use its Register() method to cache a structure value so Bind() can fill all struct's fields based on a query.
Click to show internal directories.
Click to hide internal directories.