-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.go
96 lines (91 loc) · 2.26 KB
/
types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// Copyright (C) MongoDB, Inc. 2018-present.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
package bsony
// These constants uniquely refer to each BSON type.
const (
TypeInvalid Type = 0x00
TypeDouble Type = 0x01
TypeString Type = 0x02
TypeEmbeddedDocument Type = 0x03
TypeArray Type = 0x04
TypeBinary Type = 0x05
TypeUndefined Type = 0x06
TypeObjectID Type = 0x07
TypeBoolean Type = 0x08
TypeDateTime Type = 0x09
TypeNull Type = 0x0A
TypeRegex Type = 0x0B
TypeDBPointer Type = 0x0C
TypeJavaScript Type = 0x0D
TypeSymbol Type = 0x0E
TypeCodeWithScope Type = 0x0F
TypeInt32 Type = 0x10
TypeTimestamp Type = 0x11
TypeInt64 Type = 0x12
TypeDecimal128 Type = 0x13
TypeMinKey Type = 0xFF
TypeMaxKey Type = 0x7F
)
// Type represents a BSON type.
type Type byte
// String returns the string representation of the BSON type's name.
func (bt Type) String() string {
switch bt {
case '\x00':
return "invalid"
case '\x01':
return "double"
case '\x02':
return "string"
case '\x03':
return "embedded document"
case '\x04':
return "array"
case '\x05':
return "binary"
case '\x06':
return "undefined"
case '\x07':
return "objectID"
case '\x08':
return "boolean"
case '\x09':
return "UTC datetime"
case '\x0A':
return "null"
case '\x0B':
return "regex"
case '\x0C':
return "dbPointer"
case '\x0D':
return "javascript"
case '\x0E':
return "symbol"
case '\x0F':
return "code with scope"
case '\x10':
return "32-bit integer"
case '\x11':
return "timestamp"
case '\x12':
return "64-bit integer"
case '\x13':
return "128-bit decimal"
case '\xFF':
return "min key"
case '\x7F':
return "max key"
default:
return "invalid"
}
}
// A CodeWithScope represents Javascript code with an associated scope. Unlike
// the MongoDB Go Driver's `primitive.CodeWithScope`, the CodeWithScope must be
// a `Doc` from this package.
type CodeWithScope struct {
Code string
Scope *Doc
}