Documentation ¶
Index ¶
- Variables
- type BSONSemanticIDCodec
- type BSONSemanticIDPointerCodec
- type SemanticID
- func FromString(s string) (SemanticID, error)
- func Must(sID SemanticID, err error) SemanticID
- func New(namespace string, collection string) (SemanticID, error)
- func NewDefault() (SemanticID, error)
- func NewWithCollection(collection string) (SemanticID, error)
- func NewWithNamespace(namespace string) (SemanticID, error)
Constants ¶
This section is empty.
Variables ¶
var DefaultCollection = "collection"
DefaultCollection is the collection that will be used if no collection is specified when creating a SemanticID.
var DefaultNamespace = "namespace"
DefaultNamespace is the namespace that will be used if no namespace is specified when creating a SemanticID.
var Separator = "."
Separator that will be used for all SemanticIDs. You should set this once and never change it for your application - Once you change it, SemanticIDs created before that point can't be parsed anymore. By default, this is set to `.` since this makes SemanticIDs entirely URL-safe.
Functions ¶
This section is empty.
Types ¶
type BSONSemanticIDCodec ¶
type BSONSemanticIDCodec struct{}
BSONSemanticIDCodec is a mongodb ValueCodec for encoding and decoding SemanticIDs to and from BSON.
func (*BSONSemanticIDCodec) DecodeValue ¶
func (*BSONSemanticIDCodec) DecodeValue( dc bsoncodec.DecodeContext, vr bsonrw.ValueReader, val reflect.Value, ) error
DecodeValue implements the ValueDecoder interface.
func (*BSONSemanticIDCodec) EncodeValue ¶
func (*BSONSemanticIDCodec) EncodeValue( ec bsoncodec.EncodeContext, vw bsonrw.ValueWriter, val reflect.Value, ) error
EncodeValue implements the ValueEncoder interface.
type BSONSemanticIDPointerCodec ¶
type BSONSemanticIDPointerCodec struct{}
BSONSemanticIDCodec is a mongodb ValueCodec for encoding and decoding SemanticIDs to and from BSON.
func (*BSONSemanticIDPointerCodec) DecodeValue ¶
func (*BSONSemanticIDPointerCodec) DecodeValue( dc bsoncodec.DecodeContext, vr bsonrw.ValueReader, val reflect.Value, ) error
DecodeValue implements the ValueDecoder interface.
func (*BSONSemanticIDPointerCodec) EncodeValue ¶
func (*BSONSemanticIDPointerCodec) EncodeValue( ec bsoncodec.EncodeContext, vw bsonrw.ValueWriter, val reflect.Value, ) error
EncodeValue implements the ValueEncoder interface.
type SemanticID ¶
A SemanticID is a unique identifier for an entity that consists of a namespace, a collection and a UUID.
func FromString ¶
func FromString(s string) (SemanticID, error)
FromString attempts to parse a given string into a SemanticID.
func Must ¶
func Must(sID SemanticID, err error) SemanticID
Must is a convenience function that converts errors into panics on functions that create or parse a SemanticID.
func New ¶
func New(namespace string, collection string) (SemanticID, error)
New creates a unique SemanticID with the given namespace, collection and the global separator (`.` by default).
func NewDefault ¶
func NewDefault() (SemanticID, error)
NewDefault creates a unique SemanticID with the default namespace and collection.
func NewWithCollection ¶
func NewWithCollection(collection string) (SemanticID, error)
NewWithCollection creates a unique SemanticID with the given collection and the default namespace.
func NewWithNamespace ¶
func NewWithNamespace(namespace string) (SemanticID, error)
NewWithNamespace creates a unique SemanticID with the given namespace and the default collection.
func (SemanticID) IsNil ¶
func (sID SemanticID) IsNil() bool
IsNil checks whether or not the SemanticID has any of its part set to a non-null string.
func (SemanticID) MarshalJSON ¶
func (sid SemanticID) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface for SemanticID
func (SemanticID) String ¶
func (sID SemanticID) String() string
String outputs a string representation of the SemanticID
func (*SemanticID) UnmarshalJSON ¶
func (sid *SemanticID) UnmarshalJSON(b []byte) error
UnmarshalJSON implements the json.Unmarshaler interface for SemanticID