bson

package
v0.0.0-...-3003033 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidHex = primitive.ErrInvalidHex
View Source
var Marshal = bson.Marshal

Marshal bson.Marshal

View Source
var NewObjectId = primitive.NewObjectID

NewObjectID primitive.NewObjectID

View Source
var NilObjectID = primitive.NilObjectID
View Source
var Unmarshal = bson.Unmarshal

Functions

func IsObjectIdHex

func IsObjectIdHex(s string) bool

IsObjectIDHex returns whether s is a valid hex representation of an ObjectId. See the ObjectIdHex function.

Types

type A

type A = bson.A

An A represents a BSON array. This type can be used to represent a BSON array in a concise and readable manner. It should generally be used when serializing to BSON. For deserializing, the RawArray or Array types should be used.

Example usage:

bson.A{"bar", "world", 3.14159, bson.D{{"qux", 12345}}}

type D

type D = primitive.D

D represents a BSON Document. This type can be used to represent BSON in a concise and readable manner. It should generally be used when serializing to BSON. For deserializing, the Raw or Document types should be used.

Example usage:

bson.D{{"foo", "bar"}, {"hello", "world"}, {"pi", 3.14159}}

This type should be used in situations where order matters, such as MongoDB commands. If the order is not important, a map is more comfortable and concise.

type E

type E = bson.E

E represents a BSON element for a D. It is usually used inside a D.

type M

type M = bson.M

M is an unordered, concise representation of a BSON Document. It should generally be used to serialize BSON when the order of the elements of a BSON document do not matter. If the element order matters, use a D instead.

Example usage:

bson.M{"foo": "bar", "hello": "world", "pi": 3.14159}

This type is handled in the encoders as a regular map[string]interface{}. The elements will be serialized in an undefined, random order, and the order will be different each time.

type ObjectId

type ObjectId = primitive.ObjectID

ObjectID primitive.ObjectID

func ObjectIDFromHex

func ObjectIDFromHex(s string) (ObjectId, error)

ObjectIDHex primitive.ObjectIDFromHex

func ObjectIdHex

func ObjectIdHex(s string) ObjectId

ObjectIdHex returns an ObjectId from the provided hex representation. Calling this function with an invalid hex representation will cause a runtime panic. See the IsObjectIdHex function.

type Raw

type Raw = bson.RawValue

type RegEx

type RegEx = primitive.Regex

type Zeroer

type Zeroer interface {
	IsZero() bool
}

Zeroer allows custom struct types to implement a report of zero state. All struct types that don't implement Zeroer or where IsZero returns false are considered to be not zero.

Jump to

Keyboard shortcuts

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