package objectid
import "go.mongodb.org/mongo-driver/bson/objectid"
Index ¶
Variables ¶
ErrInvalidHex indicates that a hex string cannot be converted to an ObjectID.
Types ¶
type ObjectID ¶
type ObjectID [12]byte
ObjectID is the BSON ObjectID type.
var NilObjectID ObjectID
NilObjectID is the zero value for ObjectID.
func FromHex ¶
FromHex creates a new ObjectID from a hex string. It returns an error if the hex string is not a valid ObjectID.
func New ¶
func New() ObjectID
New generates a new ObjectID.
func (ObjectID) Hex ¶
Hex returns the hex encoding of the ObjectID as a string.
func (ObjectID) 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.
Source Files ¶
objectid.go
- Version
- v0.0.8
- Published
- Jun 25, 2018
- Platform
- linux/amd64
- Imports
- 9 packages
- Last checked
- 8 seconds ago –
Tools for package owners.