Documentation
¶
Index ¶
- func AppendArrayElement(dst []byte, key string, value []byte) []byte
- func AppendBinaryElement(dst []byte, key string, subType byte, data []byte) []byte
- func AppendBooleanElement(dst []byte, key string, value bool) []byte
- func AppendCString(dst []byte, value string) []byte
- func AppendDateTimeElement(dst []byte, key string, value int64) []byte
- func AppendDocumentElement(dst []byte, key string, value []byte) []byte
- func AppendDocumentEnd(dst []byte, start int32) ([]byte, error)
- func AppendDocumentStart(dst []byte) (int32, []byte)
- func AppendDoubleElement(dst []byte, key string, value float64) []byte
- func AppendInt32(dst []byte, value int32) []byte
- func AppendInt32Element(dst []byte, key string, value int32) []byte
- func AppendInt64Element(dst []byte, key string, value int64) []byte
- func AppendInterfaceElement(dst []byte, key string, ivalue interface{}) ([]byte, error)
- func AppendNullElement(dst []byte, key string) []byte
- func AppendStringElement(dst []byte, key string, value string) []byte
- func AppendValueElement(dst []byte, key string, value Value) ([]byte, error)
- func ArrayEnd(dst []byte) ([]byte, error)
- func ArrayStart() []byte
- func DocumentEnd(dst []byte) ([]byte, error)
- func DocumentToJSONString(doc Document) (string, error)
- type Datetime
- type Dictionary
- func (dict *Dictionary) BSONBytes() (Document, error)
- func (dict *Dictionary) SetArrayElements(key string, elements []any)
- func (dict *Dictionary) SetBooleanElement(key string, element bool)
- func (dict *Dictionary) SetBytesElement(key string, element []byte)
- func (dict *Dictionary) SetDatetimeElement(key string, element Datetime)
- func (dict *Dictionary) SetDictionaryElements(key string, elements map[string]any) error
- func (dict *Dictionary) SetDocumentElement(key string, element Document)
- func (dict *Dictionary) SetDoubleElement(key string, element float64)
- func (dict *Dictionary) SetElements(elements map[string]any) error
- func (dict *Dictionary) SetInt32Element(key string, element int32)
- func (dict *Dictionary) SetInt64Element(key string, element int64)
- func (dict *Dictionary) SetNullElement(key string)
- func (dict *Dictionary) SetStringElement(key string, element string)
- type Document
- type Element
- type Value
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendArrayElement ¶ added in v1.2.0
AppendArrayElement appends an element to dst and return the extended buffer.
func AppendBinaryElement ¶ added in v1.2.0
AppendBinaryElement appends a binary element to dst and return the extended buffer.
func AppendBooleanElement ¶
AppendBooleanElement appends a boolean element to dst and return the extended buffer.
func AppendCString ¶
AppendCString appends a string as a cstring to dst and return the extended buffer.
func AppendDateTimeElement ¶
AppendDateTimeElement appends an i64 datetime to dst and return the extended buffer.
func AppendDocumentElement ¶
AppendDocumentElement appends a document to dst and return the extended buffer.
func AppendDocumentEnd ¶ added in v1.2.0
AppendDocumentEnd appends the end of the document.
func AppendDocumentStart ¶ added in v1.2.0
AppendDocumentEnd appends the end of the document.
func AppendDoubleElement ¶
AppendDoubleElement appends a float64 element to dst and return the extended buffer.
func AppendInt32 ¶
AppendInt32 appends an i32 value to dst and return the extended buffer.
func AppendInt32Element ¶
AppendInt32Element appends an i32 element to dst and return the extended buffer.
func AppendInt64Element ¶
AppendInt64Element appends an i64 element to dst and return the extended buffer.
func AppendInterfaceElement ¶
AppendInterfaceElement will append an interface element using key to dst and return the extended buffer.
func AppendNullElement ¶
AppendNullElement will append a BSON null element using key to dst and return the extended buffer.
func AppendStringElement ¶
AppendStringElement appends a string element to dst and return the extended buffer.
func AppendValueElement ¶
AppendValueElement will append a value using key to dst and return the extended buffer.
func ArrayEnd ¶ added in v1.2.0
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
DocumentEnd writes the null byte for a document and updates the length of the document.
func DocumentToJSONString ¶ added in v1.2.1
DocumentToJSONString returns the JSON string of the document.
Types ¶
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 ¶
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 NewDocumentWithBytes ¶
NewDocumentWithBytes returns a document with the specified bytes.