schema

package
v0.0.0-...-4a8b94e Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2024 License: Apache-2.0 Imports: 5 Imported by: 7

Documentation

Index

Constants

View Source
const (
	// Numeric methods
	MethodOperatorAdd = "*add"
	MethodOperatorSub = "*sub"
	MethodOperatorMul = "*mul"
	MethodOperatorDiv = "*div"
	MethodOperatorMod = "*mod"
	MethodLength      = "*len"
	MethodEquals      = "*eq"
	MethodGreater     = "*gt"
	MethodLess        = "*lt"
	MethodGreaterOE   = "*gte"
	MethodLessOE      = "*lte"
	// Array and Map methods
	MethodContains    = "*contains" // For Arrays and Maps
	MethodIndexOf     = "*indexOf"  // For Arrays
	MethodKeyOf       = "*keyOf"    // For Maps
	MethodLast        = "*last"     // Select last item of Arrays
	MethodSortAsc     = "*sortAsc"  // Sort Array in Ascending order
	MethodSortDesc    = "*sortDesc" // Sort Array in Descending order
	MethodAppend      = "*append"   // For Arrays and Maps
	MethodAppendAt    = "*append["  // Append item at array index
	MethodAppendAtFin = "]"         //   ^ End
	MethodFromTo      = ":"         // Separator for from-to Array get queries
	MethodPrepend     = "*prepend"  // For Arrays
	MethodDelete      = "*delete"   // For Arrays and Maps
	// Time methods
	MethodSince       = "*since"
	MethodUntil       = "*until"
	MethodDay         = "*day"
	MethodHour        = "*hour"
	MethodMinute      = "*min"
	MethodSecond      = "*sec"
	MethodMillisecond = "*ms"

	// Nesting queries
	MethodGet  = "*get"  // Makes a nested get query | TO-DO
	MethodThis = "*this" // Makes a nested get query for the current entry | TO-DO
)

Method names

View Source
const (
	ItemTypeBool    = "Bool"
	ItemTypeInt8    = "Int8"
	ItemTypeInt16   = "Int16"
	ItemTypeInt32   = "Int32"
	ItemTypeInt64   = "Int64"
	ItemTypeUint8   = "Uint8"
	ItemTypeUint16  = "Uint16"
	ItemTypeUint32  = "Uint32"
	ItemTypeUint64  = "Uint64"
	ItemTypeFloat32 = "Float32"
	ItemTypeFloat64 = "Float64"
	ItemTypeString  = "String"
	ItemTypeArray   = "Array"
	ItemTypeMap     = "Map"
	ItemTypeObject  = "Object"
	ItemTypeTime    = "Time"
)

Item data type names

View Source
const (
	TimeFormatANSIC       = "Mon Jan _2 15:04:05 2006"            // ANSIC
	TimeFormatUnixDate    = "Mon Jan _2 15:04:05 MST 2006"        // Unix Date
	TimeFormatRubyDate    = "Mon Jan 02 15:04:05 -0700 2006"      // Ruby Date
	TimeFormatRFC822      = "02 Jan 06 15:04 MST"                 // RFC882
	TimeFormatRFC822Z     = "02 Jan 06 15:04 -0700"               // RFC822 with numeric zone
	TimeFormatRFC850      = "Monday, 02-Jan-06 15:04:05 MST"      // RFC850
	TimeFormatRFC1123     = "Mon, 02 Jan 2006 15:04:05 MST"       // RFC1123
	TimeFormatRFC1123Z    = "Mon, 02 Jan 2006 15:04:05 -0700"     // RFC1123 with numeric zone
	TimeFormatRFC3339     = "2006-01-02T15:04:05Z07:00"           // RFC3339
	TimeFormatRFC3339Nano = "2006-01-02T15:04:05.999999999Z07:00" // RFC3339 nano
	TimeFormatKitchen     = "3:04PM"                              // Kitchen

	// Time stamp formats
	TimeFormatStamp      = "Jan _2 15:04:05"           // Time Stamp
	TimeFormatStampMilli = "Jan _2 15:04:05.000"       // Time Stamp with milliseconds
	TimeFormatStampMicro = "Jan _2 15:04:05.000000"    // Time Stamp with microseconds
	TimeFormatStampNano  = "Jan _2 15:04:05.000000000" // Time Stamp with nanoseconds
)

Time formats

Variables

This section is empty.

Functions

func GetQueryItemMethods

func GetQueryItemMethods(itemName string) (string, []string)

GetQueryItemMethods checks query item names for methods and returns the item name and the list of methods.

func GetUniqueItems

func GetUniqueItems(schema Schema, destination *[]string, outerItems string)

GetUniqueItems gets the item name (string, eg: ["login", "email"]) of all unique table items and appends them to destination.

func ItemFilter

func ItemFilter(item interface{}, methods []string, destination *interface{}, innerData interface{}, schemaItem SchemaItem, uniqueVals *map[string]interface{}, eCost int, get bool, restore bool) int

ItemFilter filters an item in a query against it's corresponding SchemaItem.

Types

type ArrayItem

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

type BoolItem

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

type Filter

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

Filter for queries

type Float32Item

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

type Float64Item

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

type Int16Item

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

type Int32Item

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

type Int64Item

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

type Int8Item

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

type MapItem

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

type ObjectItem

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

type Schema

type Schema map[string]SchemaItem

Schema represents a database schema that one or more tables must adhere to.

func New

func New(schema interface{}, restore bool) (Schema, helpers.Error)

New creates a new schema from a JSON schema object, or recovered Schema from a config file.

func Restore

func Restore(schema []SchemaConfigItem) (Schema, helpers.Error)

Restore restores a schema from a config file with it's Schema array

func (Schema) MakeConfig

func (s Schema) MakeConfig() []SchemaConfigItem

MakeConfig makes a Schema for a config file

func (Schema) Validate

func (s Schema) Validate() bool

Validate returns true if Schema is valid

type SchemaConfigItem

type SchemaConfigItem struct {
	Position uint32
	Name     string
	DataType []interface{}
}

SchemaConfigItem structures data for saving Schemas/Objects to disk in a config file.

type SchemaItem

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

SchemaItem represents one of the items in a Schema. SchemaItem also holds info about the data type and it's settings.

func (SchemaItem) DataIndex

func (si SchemaItem) DataIndex() uint32

DataIndex gets the SchemaItem data index (table specific).

func (SchemaItem) IsFloat

func (si SchemaItem) IsFloat() bool

IsFloat returns true if this SchemaItem is any float type

func (SchemaItem) IsNumeric

func (si SchemaItem) IsNumeric() bool

IsNumeric returns true if this SchemaItem is any numeric type

func (SchemaItem) QuickValidate

func (si SchemaItem) QuickValidate() bool

QuickValidate returns true if SchemaItem is "valid"

func (SchemaItem) Required

func (si SchemaItem) Required() bool

Unique returns true if the SchemaItem is unique.

func (SchemaItem) TypeName

func (si SchemaItem) TypeName() string

TypeName gets the type name of the SchemaItem.

func (SchemaItem) Unique

func (si SchemaItem) Unique() bool

Unique returns true if the SchemaItem is unique.

func (SchemaItem) Validate

func (si SchemaItem) Validate() bool

Validate returns true if SchemaItem is valid

type StringItem

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

type TimeItem

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

type Uint16Item

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

type Uint32Item

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

type Uint64Item

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

type Uint8Item

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

Jump to

Keyboard shortcuts

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