database

package
v0.0.0-...-60156bf Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2020 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Driver

type Driver struct {
	Driver   string `mapstructure:"driver"`
	Host     string `mapstructure:"host"`
	Port     int    `mapstructure:"port"`
	SSLMode  string `mapstructure:"ssl_mode"`
	Database string `mapstructure:"database"`
	Username string `mapstructure:"username"`
	Password string `mapstructure:"password"`
	Table    string `mapstructure:"table"`
}

Driver for database

type Field

type Field struct {
	Source     string    `mapstructure:"source"`
	Target     string    `mapstructure:"target"`
	TargetType FieldType `mapstructure:"target_type"`
	Converter  string    `mapstructure:"converter"`
}

Field with database mapping source database field name target database filed name target_type target database field data type TODO: converter transfer script template

type FieldMeta

type FieldMeta struct {
	Field   string
	Type    string
	Null    interface{}
	Key     interface{}
	Default interface{}
	Extra   interface{}
}

FieldMeta database table schema

type FieldType

type FieldType string

FieldType for field database field type

const (
	// FieldTimestamp timestamp type
	FieldTimestamp FieldType = "timestamp"
)

type M

type M map[string]interface{}

M transfer data type

func (M) Primitive

func (m M) Primitive() (d M, err error)

Primitive return json Marshal then Unmarshal result

type Mapping

type Mapping []*Field

Mapping for database fields map

func (Mapping) FieldMap

func (mapping Mapping) FieldMap(join ...string) M

FieldMap return select field mapping

func (Mapping) Fields

func (mapping Mapping) Fields(join ...string) (fields []string)

Fields return select fields array

func (Mapping) Map

func (mapping Mapping) Map() M

Map return field mapping

type Options

type Options struct {
	Driver  Driver
	Mapping Mapping
}

Options for transfer

type Packet

type Packet []M

Packet for transfer data

type Query

type Query struct {
	Q    interface{} `mapstructure:"q"`
	Page int         `mapstructure:"page"`
	Size int         `mapstructure:"size"`
}

Query database query

func (Query) UnmarshalQuery

func (q Query) UnmarshalQuery(v interface{}) error

UnmarshalQuery implements the json.Marshaler interface.

type Schema

type Schema []FieldMeta

Schema for database table

func (Schema) FieldMap

func (schema Schema) FieldMap() map[string]FieldMeta

FieldMap return FieldMeta map

Jump to

Keyboard shortcuts

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