Documentation ¶
Index ¶
- Constants
- func Encode(doc *Document) ([]byte, error)
- func Validate(doc *Document) error
- type Document
- func (doc *Document) AsMap() map[string]interface{}
- func (doc *Document) Copy() *Document
- func (doc *Document) ExpiresAt() *time.Time
- func (doc *Document) Fields(includeSubFields bool) []string
- func (doc *Document) Get(name string) interface{}
- func (doc *Document) Has(name string) bool
- func (doc *Document) ObjectId() string
- func (doc *Document) Set(name string, value interface{})
- func (doc *Document) SetAll(values map[string]interface{})
- func (doc *Document) SetExpiresAt(expiration time.Time)
- func (doc *Document) TTL() time.Duration
- func (doc *Document) ToMap() map[string]interface{}
- func (doc *Document) Unmarshal(v interface{}) error
Constants ¶
const ( ObjectIdField = "_id" ExpiresAtField = "_expiresAt" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Document ¶
type Document struct {
// contains filtered or unexported fields
}
Document represents a document as a map.
func NewDocumentOf ¶
func NewDocumentOf(o interface{}) *Document
NewDocumentOf creates a new document and initializes it with the content of the provided object. It returns nil if the object cannot be converted to a valid Document.
func (*Document) Fields ¶
Fields returns a lexicographically sorted slice of all available field names in the document. Nested fields, if included, are represented using dot notation.
func (*Document) Has ¶
Has tells returns true if the document contains a field with the supplied name.
func (*Document) ObjectId ¶
ObjectId returns the id of the document, provided that the document belongs to some collection. Otherwise, it returns the empty string.
func (*Document) SetAll ¶
SetAll sets each field specified in the input map to the corresponding value. Nested fields can be accessed using dot.
func (*Document) SetExpiresAt ¶
ExpiresAt sets document expiration
func (*Document) TTL ¶
TTL returns a duration representing the time to live of the document before expiration. A negative duration means that the document has no expiration, while a zero value represents an already expired document.