Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidHex = errors.New("the provided hex string is not a valid ObjectID")
ErrInvalidHex indicates that a hex string cannot be converted to an ObjectID.
var MaxKey struct{}
MaxKey represents the BSON minkey value.
var MinKey struct{}
MinKey represents the BSON maxkey value.
var Null struct{}
Null represents the BSON null value.
var Undefined struct{}
Undefined represents the BSON undefined value.
Functions ¶
This section is empty.
Types ¶
type CodeWithScope ¶
CodeWithScope represents a BSON JavaScript code with scope value.
func (CodeWithScope) String ¶
func (cws CodeWithScope) String() string
type Decimal128 ¶
type Decimal128 struct {
// contains filtered or unexported fields
}
Decimal128 holds decimal128 BSON values.
func NewDecimal128 ¶
func NewDecimal128(h, l uint64) Decimal128
NewDecimal128 creates a Decimal128 using the provide high and low uint64s.
func ParseDecimal128 ¶
func ParseDecimal128(s string) (Decimal128, error)
ParseDecimal128 takes the given string and attempts to parse it into a valid Decimal128 value.
func (Decimal128) GetBytes ¶
func (d Decimal128) GetBytes() (uint64, uint64)
GetBytes returns the underlying bytes of the BSON decimal value as two uint16 values. The first contains the most first 8 bytes of the value and the second contains the latter.
func (Decimal128) String ¶
func (d Decimal128) String() string
String returns a string representation of the decimal value.
type JavaScriptCode ¶
type JavaScriptCode string
JavaScriptCode represents a BSON JavaScript code value.
type ObjectID ¶
type ObjectID [12]byte
ObjectID is the BSON ObjectID type.
var NilObjectID ObjectID
NilObjectID is the zero value for ObjectID.
func MustObjectIDFromHex ¶
MustObjectIDFromHex builds an ObjectID, panicing if the hex string isn't valid
func ObjectIDFromHex ¶
ObjectIDFromHex creates a new ObjectID from a hex string. It returns an error if the hex string is not a valid ObjectID.
func (ObjectID) MarshalJSON ¶
MarshalJSON returns the ObjectID as a string
func (*ObjectID) UnmarshalJSON ¶
UnmarshalJSON populates the byte slice with the ObjectID. If the byte slice is 64 bytes long, it will be populated with the hex representation of the ObjectID. If the byte slice is twelve bytes long, it will be populated with the BSON representation of the ObjectID. Otherwise, it will return an error.