bson

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2024 License: Apache-2.0 Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendArrayElement added in v1.2.0

func AppendArrayElement(dst []byte, key string, value []byte) []byte

AppendArrayElement appends an element to dst and return the extended buffer.

func AppendBinaryElement added in v1.2.0

func AppendBinaryElement(dst []byte, key string, subType byte, data []byte) []byte

AppendBinaryElement appends a binary element to dst and return the extended buffer.

func AppendBooleanElement

func AppendBooleanElement(dst []byte, key string, value bool) []byte

AppendBooleanElement appends a boolean element to dst and return the extended buffer.

func AppendCString

func AppendCString(dst []byte, value string) []byte

AppendCString appends a string as a cstring to dst and return the extended buffer.

func AppendDateTimeElement

func AppendDateTimeElement(dst []byte, key string, value int64) []byte

AppendDateTimeElement appends an i64 datetime to dst and return the extended buffer.

func AppendDocumentElement

func AppendDocumentElement(dst []byte, key string, value []byte) []byte

AppendDocumentElement appends a document to dst and return the extended buffer.

func AppendDocumentEnd added in v1.2.0

func AppendDocumentEnd(dst []byte, start int32) ([]byte, error)

AppendDocumentEnd appends the end of the document.

func AppendDocumentStart added in v1.2.0

func AppendDocumentStart(dst []byte) (int32, []byte)

AppendDocumentEnd appends the end of the document.

func AppendDoubleElement

func AppendDoubleElement(dst []byte, key string, value float64) []byte

AppendDoubleElement appends a float64 element to dst and return the extended buffer.

func AppendInt32

func AppendInt32(dst []byte, value int32) []byte

AppendInt32 appends an i32 value to dst and return the extended buffer.

func AppendInt32Element

func AppendInt32Element(dst []byte, key string, value int32) []byte

AppendInt32Element appends an i32 element to dst and return the extended buffer.

func AppendInt64Element

func AppendInt64Element(dst []byte, key string, value int64) []byte

AppendInt64Element appends an i64 element to dst and return the extended buffer.

func AppendInterfaceElement

func AppendInterfaceElement(dst []byte, key string, ivalue interface{}) ([]byte, error)

AppendInterfaceElement will append an interface element using key to dst and return the extended buffer.

func AppendNullElement

func AppendNullElement(dst []byte, key string) []byte

AppendNullElement will append a BSON null element using key to dst and return the extended buffer.

func AppendStringElement

func AppendStringElement(dst []byte, key string, value string) []byte

AppendStringElement appends a string element to dst and return the extended buffer.

func AppendValueElement

func AppendValueElement(dst []byte, key string, value Value) ([]byte, error)

AppendValueElement will append a value using key to dst and return the extended buffer.

func ArrayEnd added in v1.2.0

func ArrayEnd(dst []byte) ([]byte, error)

AppendArrayEnd writes the null byte for an array and updates the length of the array.

func ArrayStart added in v1.2.0

func ArrayStart() []byte

AppendArrayStart returns a new array which has only the reserved length header.

func DocumentEnd added in v1.2.0

func DocumentEnd(dst []byte) ([]byte, error)

DocumentEnd writes the null byte for a document and updates the length of the document.

func DocumentToJSONString added in v1.2.1

func DocumentToJSONString(doc Document) (string, error)

DocumentToJSONString returns the JSON string of the document.

Types

type Datetime

type Datetime int64

Datetime is UTC milliseconds since the Unix epoch.

type Dictionary

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

Dictionary represents a simple BSON document.

func NewDictionary

func NewDictionary() *Dictionary

NewDictionary returns a new dictionary instance.

func (*Dictionary) BSONBytes

func (dict *Dictionary) BSONBytes() (Document, error)

See : BSON Specification Version 1.1 http://bsonspec.org/spec.html BSONBytes returns a BSON document of the dictionary.

func (*Dictionary) SetArrayElements added in v1.2.0

func (dict *Dictionary) SetArrayElements(key string, elements []any)

SetArrayElements sets an array elements.

func (*Dictionary) SetBooleanElement

func (dict *Dictionary) SetBooleanElement(key string, element bool)

SetBooleanElement sets a boolean element.

func (*Dictionary) SetBytesElement added in v1.2.0

func (dict *Dictionary) SetBytesElement(key string, element []byte)

SetBytesElement sets a byte array element.

func (*Dictionary) SetDatetimeElement

func (dict *Dictionary) SetDatetimeElement(key string, element Datetime)

SetDatetimeElement sets a datetime element.

func (*Dictionary) SetDictionaryElements added in v1.2.0

func (dict *Dictionary) SetDictionaryElements(key string, elements map[string]any) error

SetDictionaryElements sets a dictionary elements.

func (*Dictionary) SetDocumentElement

func (dict *Dictionary) SetDocumentElement(key string, element Document)

SetDocumentElement sets a document element.

func (*Dictionary) SetDoubleElement

func (dict *Dictionary) SetDoubleElement(key string, element float64)

SetDoubleElement sets a int64 element.

func (*Dictionary) SetElements

func (dict *Dictionary) SetElements(elements map[string]any) error

SetElements sets elements.

func (*Dictionary) SetInt32Element

func (dict *Dictionary) SetInt32Element(key string, element int32)

SetInt32Element sets a int32 element.

func (*Dictionary) SetInt64Element

func (dict *Dictionary) SetInt64Element(key string, element int64)

SetInt64Element sets a int64 element.

func (*Dictionary) SetNullElement

func (dict *Dictionary) SetNullElement(key string)

SetNullElement sets a null element.

func (*Dictionary) SetStringElement

func (dict *Dictionary) SetStringElement(key string, element string)

SetStringElement sets a string element.

type Document

type Document = bsoncore.Document

Document represents a document of MongoDB wire protocol.

func DocumentStart added in v1.2.0

func DocumentStart() Document

DocumentStart returns a new document which has only the reserved length header.

func NewDocument

func NewDocument() Document

NewDocument returns a new document.

func NewDocumentWithBytes

func NewDocumentWithBytes(src []byte) (Document, error)

NewDocumentWithBytes returns a document with the specified bytes.

type Element

type Element = bsoncore.Element

Element represents an element of MongoDB wire protocol.

func NewElement

func NewElement() Element

NewElement returns a new element.

type Value

type Value = bsoncore.Value

Value represents an value of MongoDB wire protocol.

Jump to

Keyboard shortcuts

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