bson

package
v1.1.43 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Marshal = bson.Marshal

Marshal bson.Marshal

View Source
var NewObjectID = primitive.NewObjectID

NewObjectID primitive.NewObjectID

ObjectIDHex primitive.ObjectIDFromHex

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 = primitive.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 = primitive.E

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

type M

type M = primitive.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

type Zeroed

type Zeroed interface {
	IsZero() bool
}

Zeroed allows custom struct types to implement a report of zero state. All struct types that don't implement Zeroed 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