bsonmodel

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const Version = "1.0.0-dev"

Variables

This section is empty.

Functions

func AnyDateTimeValue

func AnyDateTimeValue(any jsoniter.Any) (t time.Time, err error)

func AnyDateValue

func AnyDateValue(any jsoniter.Any) (t time.Time, err error)

func AnyFloat64Value

func AnyFloat64Value(any jsoniter.Any, def float64) (float64, error)

func AnyIntArrayValue

func AnyIntArrayValue(any jsoniter.Any) ([]int, error)

func AnyIntValue

func AnyIntValue(any jsoniter.Any, def int) (int, error)

func AnyStringArrayValue

func AnyStringArrayValue(any jsoniter.Any) ([]string, error)

func AnyStringValue

func AnyStringValue(any jsoniter.Any, def string) (string, error)

func DateTimeValue

func DateTimeValue(m bson.M, name string) (t time.Time, err error)

func DateToNumber

func DateToNumber(date time.Time) int

func DateValue

func DateValue(m bson.M, name string) (t time.Time, err error)

func EmbeddedValue

func EmbeddedValue(m bson.M, name string) (bson.M, error)

func FixedEmbedded

func FixedEmbedded(m bson.M, name string) bson.M

func Float64Value

func Float64Value(m bson.M, name string, def float64) (float64, error)

func IntArrayValue

func IntArrayValue(m bson.M, name string) ([]int, error)

func IntValue

func IntValue(m bson.M, name string, def int) (int, error)

func NumberToDate

func NumberToDate(num int) time.Time

func StringArrayValue

func StringArrayValue(m bson.M, name string) ([]string, error)

func StringValue

func StringValue(m bson.M, name string, def string) (string, error)

Types

type BaseIntObjectMapValue

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

func (*BaseIntObjectMapValue) EmitUpdated

func (v *BaseIntObjectMapValue) EmitUpdated()

func (*BaseIntObjectMapValue) Key

func (v *BaseIntObjectMapValue) Key() int

func (*BaseIntObjectMapValue) Parent

func (v *BaseIntObjectMapValue) Parent() BsonModel

func (*BaseIntObjectMapValue) XPath

type BaseStringObjectMapValue

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

func (*BaseStringObjectMapValue) EmitUpdated

func (v *BaseStringObjectMapValue) EmitUpdated()

func (*BaseStringObjectMapValue) Key

func (*BaseStringObjectMapValue) Parent

func (v *BaseStringObjectMapValue) Parent() BsonModel

func (*BaseStringObjectMapValue) XPath

type BsonModel

type BsonModel interface {
	ToBson() interface{}
	ToData() interface{}
	LoadJsoniter(any jsoniter.Any) error
	Reset()
	AnyUpdated() bool
	AnyDeleted() bool
	Parent() BsonModel
	XPath() DotNotation
	AppendUpdates(updates bson.M) bson.M
	ToSync() interface{}
	ToDelete() interface{}
	ToDataJson() (string, error)
	ToSyncJson() (string, error)
	ToDeleteJson() (string, error)
}

The top interface for BSON model.

type DocumentModel

type DocumentModel interface {
	BsonModel
	ToDocument() bson.M
	LoadDocument(document bson.M) error
	DeletedSize() int
}

type DotNotation

type DotNotation interface {
	Value() string
	IsRoot() bool
	Resolve(name string) DotNotation
	ResolveIndex(index int) DotNotation
}

DotNotation defines BSON dot notation.

func PathOf

func PathOf(base DotNotation, names ...string) DotNotation

func PathOfNames

func PathOfNames(base string, names ...string) DotNotation

func RootPath

func RootPath() DotNotation

type IntObjectMapModel

type IntObjectMapModel interface {
	Keys() []int
	Get(key int) IntObjectMapValueModel
	Put(key int, value IntObjectMapValueModel) IntObjectMapValueModel
	Remove(key int) bool
	SetUpdated(key string)
	// contains filtered or unexported methods
}

func NewIntObjectMapModel

func NewIntObjectMapModel(parent BsonModel, name string, valueFactory IntObjectMapValueFactory) IntObjectMapModel

type IntObjectMapValueFactory

type IntObjectMapValueFactory func() IntObjectMapValueModel

type IntObjectMapValueModel

type IntObjectMapValueModel interface {
	MapValueModel

	Key() int
	// contains filtered or unexported methods
}

type IntSimpleMapModel

type IntSimpleMapModel interface {
	Keys() []int
	Get(key int) interface{}
	Put(key int, value interface{}) interface{}
	Remove(key int) bool
	// contains filtered or unexported methods
}

func NewIntSimpleMapModel

func NewIntSimpleMapModel(parent BsonModel, name string, valueType SimpleValueType) IntSimpleMapModel

type MapValueModel

type MapValueModel interface {
	ObjectModel

	EmitUpdated()
	// contains filtered or unexported methods
}

type ObjectModel

type ObjectModel interface {
	DocumentModel
	FullyUpdate() bool
	SetFullyUpdate(fullyUpdate bool)
}

type RootModel

type RootModel interface {
	ObjectModel
	ToUpdate() bson.M
	MarshalToJsonString() (string, error)
}

type SimpleValueType

type SimpleValueType interface {
	Parse(value interface{}) (interface{}, error)
	ParseJsoniter(value jsoniter.Any) (interface{}, error)
	ToBson(value interface{}) interface{}
	ToData(value interface{}) interface{}
}

func BoolValueType

func BoolValueType() SimpleValueType

func DateSimpleValueType

func DateSimpleValueType() SimpleValueType

func DateTimeSimpleValueType

func DateTimeSimpleValueType() SimpleValueType

func Float64ValueType

func Float64ValueType() SimpleValueType

func IntValueType

func IntValueType() SimpleValueType

func StringValeType

func StringValeType() SimpleValueType

type StringObjectMapModel

type StringObjectMapModel interface {
	Keys() []string
	Get(key string) StringObjectMapValueModel
	Put(key string, value StringObjectMapValueModel) StringObjectMapValueModel
	Remove(key string) bool
	SetUpdated(key string)
	// contains filtered or unexported methods
}

func NewStringObjectMapModel

func NewStringObjectMapModel(parent BsonModel, name string, valueFactory StringObjectMapValueFactory) StringObjectMapModel

type StringObjectMapValueFactory

type StringObjectMapValueFactory func() StringObjectMapValueModel

type StringObjectMapValueModel

type StringObjectMapValueModel interface {
	MapValueModel
	Key() string
	// contains filtered or unexported methods
}

type StringSimpleMapModel

type StringSimpleMapModel interface {
	Keys() []string
	Get(key string) interface{}
	Put(key string, value interface{}) interface{}
	Remove(key string) bool
	// contains filtered or unexported methods
}

func NewStringSimpleMapModel

func NewStringSimpleMapModel(parent BsonModel, name string, valueType SimpleValueType) StringSimpleMapModel

Jump to

Keyboard shortcuts

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