bsonex

package module
v1.2.4 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2023 License: MIT Imports: 14 Imported by: 1

README

bsonex

fast and easy to use bson package.

Documentation

Index

Constants

View Source
const (
	TypeEmpty       ValueType = iota
	TypeDouble                // 0x01 64-bit binary floating point
	TypeString                // 0x02 UTF-8 string
	TypeDocument              // 0x03 Embedded document
	TypeArray                 // 0x04
	TypeBinary                // 0x05 Binary data
	TypeUndefined             // 0x06 Undefined (value) — Deprecated
	TypeObjectId              // 0x07
	TypeBoolean               // 0x08
	TypeDatetime              // 0x09 UTC datetime
	TypeNull                  // 0x0A
	TypeRegex                 // 0x0B Regular expression
	TypeDBPointer             // 0x0C Deprecated
	TypeJSCode                // 0x0D
	TypeSymbol                // 0x0E Deprecated
	TypeJSCodeScope           // 0x0F Deprecated
	TypeInt32                 // 0x10
	TypeTimestamp             // 0x11
	TypeInt64                 // 0x12
	TypeDecimal128            // 0x13 128-bit decimal floating point
	TypeMinKey      byte      = 0xFF
	TypeMaxKey      byte      = 0x7F
)

Variables

View Source
var (
	Undefined         = gbson.Undefined
	MinKey            = gbson.MinKey
	MaxKey            = gbson.MaxKey
	NewObjectId       = gbson.NewObjectId
	NewMongoTimestamp = gbson.NewMongoTimestamp
	Marshal           = gbson.Marshal
	Unmarshal         = gbson.Unmarshal
	NewEncoder        = gbson.NewEncoder
	ReadOne           = bson.ReadOne
)

Functions

func NewToSearchValue added in v1.1.0

func NewToSearchValue(v interface{}) (b toSearchValue, err error)

Types

type BSON

type BSON []byte

func (BSON) Array added in v1.2.0

func (b BSON) Array() (arr []interface{})

func (BSON) FastContains added in v1.1.0

func (b BSON) FastContains(v toSearchValue) bool

FastContains 可以在未解析BSON的时候先快速判断一下是否包含待查找的内容, 避免执行每个文档都执行Unmarshal加快查找速度。 需要注意的是这里查找并不精确,必要的情况下仍然需要再次Unmarshal再确认一次。

func (BSON) Lookup

func (b BSON) Lookup(key string) (val Value)

func (BSON) Map

func (b BSON) Map() (vals M)

func (BSON) MustToJson

func (b BSON) MustToJson() (s []byte)

func (BSON) String

func (b BSON) String() string

func (BSON) ToJson

func (b BSON) ToJson() (s []byte, err error)

func (BSON) ToValueArray added in v1.2.0

func (b BSON) ToValueArray() (arr []Value)

func (BSON) ToValueMap

func (b BSON) ToValueMap() (vals map[string]Value)

func (BSON) Unmarshal

func (b BSON) Unmarshal(out interface{}) (err error)

type BSONEX

type BSONEX struct {
	BSON
	// contains filtered or unexported fields
}

func (*BSONEX) Offset

func (b *BSONEX) Offset() int64

func (*BSONEX) RunnerID

func (b *BSONEX) RunnerID() int

func (*BSONEX) Size

func (b *BSONEX) Size() int

func (BSONEX) String

func (b BSONEX) String() string

type Binary

type Binary struct {
	gbson.Binary
}

func (Binary) GetBSON added in v1.2.4

func (v Binary) GetBSON() (interface{}, error)

func (Binary) MarshalJSON

func (b Binary) MarshalJSON() (bs []byte, err error)

type DBPointer added in v1.2.4

type DBPointer = gbson.DBPointer

type Decoder

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

func NewDecoder

func NewDecoder(r io.Reader) *Decoder

func (*Decoder) Decode

func (d *Decoder) Decode(v interface{}) (err error)

func (*Decoder) Do

func (d *Decoder) Do(parallel int, f func(b BSONEX) error) (err error)

func (*Decoder) ForEach

func (d *Decoder) ForEach(f func(b BSONEX) error) (err error)

func (*Decoder) ReadOne

func (d *Decoder) ReadOne() (one []byte, err error)

type M

type M = gbson.M

type MongoTimestamp added in v1.2.4

type MongoTimestamp = gbson.MongoTimestamp

type ObjectId added in v1.2.4

type ObjectId = gbson.ObjectId

type RegEx added in v1.2.4

type RegEx = gbson.RegEx

type Value

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

func (Value) Array added in v1.2.0

func (v Value) Array() (a []interface{})

func (Value) ArrayOf

func (v Value) ArrayOf(i int) Value

func (Value) Binary

func (v Value) Binary() Binary

func (Value) Bool

func (v Value) Bool() bool

func (Value) DBPointer

func (v Value) DBPointer() DBPointer

func (Value) Document

func (v Value) Document() BSON

func (Value) Float64

func (v Value) Float64() float64

func (Value) GetBSON added in v1.2.4

func (v Value) GetBSON() (interface{}, error)

func (Value) Int32

func (v Value) Int32() int32

func (Value) Int64

func (v Value) Int64() int64

func (Value) IsEmpty added in v1.1.0

func (v Value) IsEmpty() bool

func (Value) IsMaxKey

func (v Value) IsMaxKey() bool

func (Value) IsMinKey

func (v Value) IsMinKey() bool

func (Value) IsNull

func (v Value) IsNull() bool

func (Value) IsUndefined

func (v Value) IsUndefined() bool

func (Value) Map added in v1.2.1

func (v Value) Map() M

func (Value) MarshalBSON added in v1.2.1

func (v Value) MarshalBSON() (bs []byte, err error)

func (Value) MarshalJSON added in v1.2.1

func (v Value) MarshalJSON() (bs []byte, err error)

func (Value) MongoTimestamp

func (v Value) MongoTimestamp() MongoTimestamp

func (Value) Objid

func (v Value) Objid() ObjectId

func (Value) RawValue

func (v Value) RawValue() []byte

func (Value) Regexp

func (v Value) Regexp() RegEx

func (Value) Str

func (v Value) Str() string

func (Value) String

func (v Value) String() string

func (Value) Time

func (v Value) Time() time.Time

func (Value) Type

func (v Value) Type() ValueType

func (Value) Uint32

func (v Value) Uint32() uint32

func (Value) Uint64

func (v Value) Uint64() uint64

func (Value) Value

func (v Value) Value() (r interface{})

func (Value) ValueArray added in v1.2.1

func (v Value) ValueArray() (a []Value)

func (Value) ValueMap added in v1.2.1

func (v Value) ValueMap() map[string]Value

type ValueType added in v1.2.0

type ValueType = byte

Directories

Path Synopsis
tools

Jump to

Keyboard shortcuts

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