bsonutil

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2025 License: MIT Imports: 6 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

bsonutil

This is a utility library with various methods, interface implementations, etc. to interface with bson

Documentation

Index

Constants

View Source
const MaxBsonObjectSize = 16777216

Variables

This section is empty.

Functions

func BoolNumber

func BoolNumber(v interface{}) bool

BoolNumber returns the "bool" status of the result (assuming its a number)

func GetBoolDefault

func GetBoolDefault(in *bool, d bool) bool

func Lookup

func Lookup(in bson.D, keys ...string) (interface{}, bool)

func Ok

func Ok(in bson.D) bool

Ok returns the "ok" status of the result. This is required as mongo is very inconsistent on the type it uses for "ok"; so this saves all of the type switching across the codebase

func Pop

func Pop(in bson.D, keys ...string) (bson.D, interface{}, bool)

Types

type ArrayReader

type ArrayReader struct {
	A interface{}
	// contains filtered or unexported fields
}

func NewArrayReader

func NewArrayReader(a interface{}, disallow bool) *ArrayReader

func (*ArrayReader) ReadValue

func (r *ArrayReader) ReadValue() (bsonrw.ValueReader, error)

type BSONValueReader

type BSONValueReader struct {
	// contains filtered or unexported fields
}

func NewStrictValueReader

func NewStrictValueReader(in interface{}) *BSONValueReader

func NewValueReader

func NewValueReader(in interface{}, disallow bool) *BSONValueReader

func (*BSONValueReader) ReadArray

func (r *BSONValueReader) ReadArray() (bsonrw.ArrayReader, error)

func (*BSONValueReader) ReadBinary

func (r *BSONValueReader) ReadBinary() (b []byte, btype byte, err error)

func (*BSONValueReader) ReadBoolean

func (r *BSONValueReader) ReadBoolean() (bool, error)

func (*BSONValueReader) ReadCodeWithScope

func (r *BSONValueReader) ReadCodeWithScope() (code string, dr bsonrw.DocumentReader, err error)

func (*BSONValueReader) ReadDBPointer

func (r *BSONValueReader) ReadDBPointer() (ns string, oid primitive.ObjectID, err error)

func (*BSONValueReader) ReadDateTime

func (r *BSONValueReader) ReadDateTime() (int64, error)

func (*BSONValueReader) ReadDecimal128

func (r *BSONValueReader) ReadDecimal128() (primitive.Decimal128, error)

func (*BSONValueReader) ReadDocument

func (r *BSONValueReader) ReadDocument() (bsonrw.DocumentReader, error)

func (*BSONValueReader) ReadDouble

func (r *BSONValueReader) ReadDouble() (float64, error)

func (*BSONValueReader) ReadInt32

func (r *BSONValueReader) ReadInt32() (int32, error)

func (*BSONValueReader) ReadInt64

func (r *BSONValueReader) ReadInt64() (int64, error)

func (*BSONValueReader) ReadJavascript

func (r *BSONValueReader) ReadJavascript() (code string, err error)

func (*BSONValueReader) ReadMaxKey

func (r *BSONValueReader) ReadMaxKey() error

func (*BSONValueReader) ReadMinKey

func (r *BSONValueReader) ReadMinKey() error

func (*BSONValueReader) ReadNull

func (r *BSONValueReader) ReadNull() error

func (*BSONValueReader) ReadObjectID

func (r *BSONValueReader) ReadObjectID() (primitive.ObjectID, error)

func (*BSONValueReader) ReadRegex

func (r *BSONValueReader) ReadRegex() (pattern, options string, err error)

func (*BSONValueReader) ReadString

func (r *BSONValueReader) ReadString() (string, error)

func (*BSONValueReader) ReadSymbol

func (r *BSONValueReader) ReadSymbol() (symbol string, err error)

func (*BSONValueReader) ReadTimestamp

func (r *BSONValueReader) ReadTimestamp() (t, i uint32, err error)

func (*BSONValueReader) ReadUndefined

func (r *BSONValueReader) ReadUndefined() error

func (*BSONValueReader) SetKey

func (r *BSONValueReader) SetKey(k string)

func (*BSONValueReader) Skip

func (r *BSONValueReader) Skip() error

Skip is called when a value is going to be skipped; so this allows us to be "pedantic" or return an error if there is an unknown field

func (*BSONValueReader) Type

func (r *BSONValueReader) Type() bsontype.Type

type DocumentReader

type DocumentReader struct {
	V interface{}
	// contains filtered or unexported fields
}

func NewDocumentReader

func NewDocumentReader(v interface{}, disallow bool) *DocumentReader

func (*DocumentReader) ReadElement

func (r *DocumentReader) ReadElement() (string, bsonrw.ValueReader, error)

type UpdateFields

type UpdateFields struct {
	Create []string
	Update []string
	Delete []string
}

func ExpandUpdate

func ExpandUpdate(d bson.D, ups *bool) UpdateFields

ExpandUpdate expands the update to a set of fields that will be CRUD

Jump to

Keyboard shortcuts

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