xun

package module
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2022 License: Apache-2.0 Imports: 11 Imported by: 5

README

Xun Database

UnitTest codecov Go Report Card Go Reference

Xun Database is an object-relational mapper (ORM), that is written in golang and supports JSON schema. Xun providing query builder and schema builder, can change the table structure at run time, especially suitable for use in Low-Code application.

The name Xun comes from the Chinese word 巽(xùn). It is one of the eight trigrams, a symbol of wind. it also symbolizes the object filled in everywhere.

https://yaoapps.com

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CastType

func CastType(value *reflect.Value, from reflect.Kind, to reflect.Kind) bool

CastType cast type

func GetTagName

func GetTagName(field reflect.StructField, name string) string

GetTagName get the tag name of the reflect.StructField

func ToSnakeCase

func ToSnakeCase(str string) string

ToSnakeCase convert camel case string to snake case

func UpperFirst

func UpperFirst(str string) string

UpperFirst upcase the first letter

Types

type N

type N struct {
	Number interface{}
}

N an numberic value, R is the first letter of "Numberic"

func MakeN

func MakeN(v interface{}) N

MakeN Create a new xun.N struct

func MakeNum

func MakeNum(v interface{}) N

MakeNum Create a new xun.N struct ( alias MakeN )

func (N) Float64

func (n N) Float64() (float64, error)

Float64 the return value is the type of float64

func (N) Int

func (n N) Int() (int, error)

Int the return value is the type of int and remove the decimal

func (N) Int32

func (n N) Int32() (int32, error)

Int32 the return value is the type of int64 and remove the decimal

func (N) Int64

func (n N) Int64() (int64, error)

Int64 the return value is the type of int64 and remove the decimal

func (*N) MarshalJSON

func (n *N) MarshalJSON() ([]byte, error)

MarshalJSON for json marshalJSON

func (N) MustFloat64

func (n N) MustFloat64() float64

MustFloat64 the return value is the type of float64

func (N) MustInt

func (n N) MustInt() int

MustInt the return value is the type of int and remove the decimal

func (N) MustInt32

func (n N) MustInt32() int32

MustInt32 the return value is the type of int64 and remove the decimal

func (N) MustInt64

func (n N) MustInt64() int64

MustInt64 the return value is the type of int64 and remove the decimal

func (N) MustToFixed

func (n N) MustToFixed(places int) float64

MustToFixed the return value is the type of float64 and keeps the given decimal places

func (*N) Scan

func (n *N) Scan(src interface{}) error

Scan for db scan

func (N) ToFixed

func (n N) ToFixed(places int) (float64, error)

ToFixed the return value is the type of float64 and keeps the given decimal places

func (*N) UnmarshalJSON

func (n *N) UnmarshalJSON(data []byte) error

UnmarshalJSON for json marshalJSON

func (*N) Value

func (n *N) Value() (driver.Value, error)

Value for db driver value

type P

type P struct {
	Items        []interface{}          `json:"items"`
	Total        int                    `json:"total"`
	TotalPages   int                    `json:"total_pages"`
	PageSize     int                    `json:"page_size"`
	CurrentPage  int                    `json:"current_page"`
	NextPage     int                    `json:"next_page"`
	PreviousPage int                    `json:"previous_page"`
	LastPage     int                    `json:"last_page"`
	Options      map[string]interface{} `json:"options,omtempty"`
}

P an Paginator struct, P is the first letter of "Paginator"

func MakeP

func MakeP(total int, pageSize int, currentPage int, items ...interface{}) P

MakeP create a new P struct

func MakePaginator

func MakePaginator(total int, pageSize int, currentPage int, items ...interface{}) P

MakePaginator create a new P struct alias MakeP

type R

type R map[string]interface{}

R alias map[string]interface{}, R is the first letter of "Row"

func MakeR

func MakeR(value ...interface{}) R

MakeR create a new R struct

func MakeRSlice

func MakeRSlice(value ...interface{}) []R

MakeRSlice convert any struct to R slice

func MakeRow

func MakeRow(value ...interface{}) R

MakeRow create a new R struct alias MakeR

func MakeRows

func MakeRows(value ...interface{}) []R

MakeRows convert any struct to R slice alias MakeRSlice

func (R) Del

func (row R) Del(key string)

Del delete value with given key

func (R) Get

func (row R) Get(key interface{}) interface{}

Get get the value of the given key

func (R) GetBool

func (row R) GetBool(key interface{}) bool

GetBool get the int value of the given key

func (R) GetFloat

func (row R) GetFloat(key interface{}, places int) float64

GetFloat get the float value of the given key

func (R) GetInt

func (row R) GetInt(key interface{}) int

GetInt get the int value of the given key

func (R) GetString

func (row R) GetString(key interface{}) string

GetString get the string value of the given key

func (R) GetTime

func (row R) GetTime(key interface{}) T

GetTime get the value of the given key, and cast the type to xun.T

func (R) Has

func (row R) Has(key string) bool

Has detemind if has the given key

func (R) IsEmpty

func (row R) IsEmpty() bool

IsEmpty determine if the row is null

func (R) Keys

func (row R) Keys() []interface{}

Keys get keys of R

func (R) KeysString

func (row R) KeysString() []string

KeysString get keys of R

func (*R) Merge

func (row *R) Merge(v ...interface{})

Merge get keys of R

func (R) MustGet

func (row R) MustGet(key interface{}) interface{}

MustGet get the value of the given key, if key does not exits painc

func (R) ToMap

func (row R) ToMap() map[string]interface{}

ToMap cast to map[string]interface{}

func (R) Value

func (row R) Value(key interface{}) interface{}

Value get the value of the given key ( alias Get)

type T

type T struct {
	Time interface{}
}

T an datetime value, T is the first letter of "Time"

func MakeTime

func MakeTime(value ...interface{}) T

MakeTime Create a new time struct

func (T) IsNull

func (t T) IsNull() bool

IsNull determine if the time is null

func (*T) MarshalJSON

func (t *T) MarshalJSON() ([]byte, error)

MarshalJSON for json marshalJSON

func (T) MustToTime

func (t T) MustToTime(formats ...string) time.Time

MustToTime cast the T to time.Time

func (*T) Scan

func (t *T) Scan(src interface{}) error

Scan for db scan

func (T) ToTime

func (t T) ToTime(formats ...string) (time.Time, error)

ToTime cast the T to time.Time

func (*T) UnmarshalJSON

func (t *T) UnmarshalJSON(data []byte) error

UnmarshalJSON for json marshalJSON

func (*T) Value

func (t *T) Value() (driver.Value, error)

Value for db driver value

type UploadFile

type UploadFile struct {
	Name     string
	TempFile string
	Size     int64
	Header   textproto.MIMEHeader
}

UploadFile upload file

Directories

Path Synopsis
grammar
sql

Jump to

Keyboard shortcuts

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