bson

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: May 4, 2023 License: Apache-2.0 Imports: 5 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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 Document) []byte

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

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 EndDocument

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

EndDocument writes the null byte for a document and updates the length 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) SetBooleanElement

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

SetBooleanElement sets a boolean element.

func (*Dictionary) SetDatetimeElement

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

SetDatetimeElement sets a datetime element.

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]interface{}) error

SetElements sets elements.

func (*Dictionary) SetInt32ArrayElements

func (dict *Dictionary) SetInt32ArrayElements(key string, elements []int32)

SetInt32ArrayElements sets an interger array element.

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 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.

func StartDocument

func StartDocument() Document

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

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