Documentation
¶
Overview ¶
Package types provides Go types matching BSON types without built-in Go equivalents.
All BSON data types have three representations in SAP HANA compatibility layer for MongoDB Wire Protocol:
- As they are used in handlers implementation (types package).
- As they are used in the wire protocol implementation (bson package).
- As they are used to store data in PostgreSQL (fjson package).
The reason for that is a separation of concerns: to avoid method names clashes, to simplify type asserts, etc.
Mapping ¶
Composite/pointer types
types.Document *bson.Document *fjson.Document *types.Array *bson.Array *fjson.Array
Scalar/value types
float64 *bson.Double *fjson.Double string *bson.String *fjson.String types.Binary *bson.Binary *fjson.Binary types.ObjectID *bson.ObjectID *fjson.ObjectID bool *bson.Bool *fjson.Bool time.Time *bson.DateTime *fjson.DateTime any(nil) any(nil) any(nil) types.Regex *bson.Regex *fjson.Regex int32 *bson.Int32 *fjson.Int32 types.Timestamp *bson.Timestamp *fjson.Timestamp int64 *bson.Int64 *fjson.Int64 TODO Decimal128 types.CString *bson.CString *fjson.CString
Index ¶
- Constants
- Variables
- type Array
- func (a *Array) Append(values ...any) error
- func (a *Array) Contains(key string) bool
- func (a *Array) Delete(index int) (err error)
- func (a *Array) Get(index int) (any, error)
- func (a *Array) GetByPath(path ...string) (any, error)
- func (a *Array) GetPointer(index int) (*any, error)
- func (a *Array) Len() int
- func (a *Array) Set(index int, value any) error
- func (a *Array) Subslice(low, high int) (*Array, error)
- type Binary
- type BinarySubtype
- type CString
- type CompareResult
- type CompositeType
- type Document
- func (d Document) Command() string
- func (d Document) Get(key string) (any, error)
- func (d Document) GetByPath(path ...string) (any, error)
- func (d Document) Keys() []string
- func (d Document) Map() map[string]any
- func (d *Document) Remove(key string)
- func (d *Document) Set(key string, value any) error
- type NullType
- type ObjectID
- type Regex
- type Timestamp
Constants ¶
const ( BinaryGeneric = BinarySubtype(0x00) // generic BinaryFunction = BinarySubtype(0x01) // function BinaryGenericOld = BinarySubtype(0x02) // generic-old BinaryUUIDOld = BinarySubtype(0x03) // uuid-old BinaryUUID = BinarySubtype(0x04) // uuid BinaryMD5 = BinarySubtype(0x05) // md5 BinaryEncrypted = BinarySubtype(0x06) // encrypted BinaryUser = BinarySubtype(0x80) // user )
Variables ¶
var Null = NullType{}
Functions ¶
This section is empty.
Types ¶
type Array ¶
type Array struct {
// contains filtered or unexported fields
}
Array represents BSON array.
Zero value is a valid empty array.
func MustNewArray ¶
MustNewArray is a NewArray that panics in case of error.
type Binary ¶
type Binary struct { Subtype BinarySubtype B []byte }
type BinarySubtype ¶
type BinarySubtype byte
func (BinarySubtype) String ¶
func (i BinarySubtype) String() string
type CompareResult ¶
type CompareResult int
compareResult represents the result of a comparison.
func CompareScalars ¶
func CompareScalars(a, b any) CompareResult
compareScalars compares two scalar values.
type CompositeType ¶
type CompositeType interface { Document | *Array GetByPath(path ...string) (any, error) // contains filtered or unexported methods }
CompositeType represents composite/pointer type - Document or *Array.
type Document ¶
type Document struct {
// contains filtered or unexported fields
}
Document represents BSON document.
Duplicate field names are not supported.
func ConvertDocument ¶
ConvertDocument converts bson.Document to types.Document and validates it. It references the same data without copying it.
func MakeDocument ¶
MakeDocument makes a new Document from given key/value pairs.
func MustConvertDocument ¶
func MustConvertDocument(d document) Document
MustConvertDocument is a ConvertDocument that panics in case of error.
func MustMakeDocument ¶
MustMakeDocument is a MakeDocument that panics in case of error.
func MustMakeDocumentPointer ¶
MustMakeDocument is a MakeDocument that panics in case of error.
func (Document) Command ¶
Command returns the first document's key, this is often used as a command name.