Documentation ¶
Index ¶
- Constants
- func ParseKey(key string) (dbName, dbKey string)
- func Unwrap(wrapped, new Record) error
- type Base
- func (b *Base) CreateMeta()
- func (b *Base) DatabaseKey() string
- func (b *Base) DatabaseName() string
- func (b *Base) GetAccessor(self Record) accessor.Accessor
- func (b *Base) IsWrapped() bool
- func (b *Base) Key() string
- func (b *Base) KeyIsSet() bool
- func (b *Base) Marshal(self Record, format uint8) ([]byte, error)
- func (b *Base) MarshalRecord(self Record) ([]byte, error)
- func (b *Base) Meta() *Meta
- func (b *Base) SetKey(key string)
- func (b *Base) SetMeta(meta *Meta)
- func (b *Base) UpdateMeta()
- type Meta
- func (m *Meta) CheckPermission(local, internal bool) (permitted bool)
- func (m *Meta) CheckValidity() (valid bool)
- func (m *Meta) Delete()
- func (m *Meta) Duplicate() *Meta
- func (m *Meta) GenCodeMarshal(buf []byte) ([]byte, error)
- func (m *Meta) GenCodeSize() (s int)
- func (m *Meta) GenCodeUnmarshal(buf []byte) (uint64, error)
- func (m *Meta) GetAbsoluteExpiry() int64
- func (m *Meta) GetRelativeExpiry() int64
- func (m *Meta) IsDeleted() bool
- func (m *Meta) MakeCrownJewel()
- func (m *Meta) MakeSecret()
- func (m *Meta) Reset()
- func (m *Meta) SetAbsoluteExpiry(seconds int64)
- func (m *Meta) SetRelativateExpiry(seconds int64)
- func (m *Meta) Update()
- type Record
- type Wrapper
Constants ¶
const ( AUTO = dsd.AUTO STRING = dsd.STRING // S BYTES = dsd.BYTES // X JSON = dsd.JSON // J BSON = dsd.BSON // B GenCode = dsd.GenCode // G )
Reimport DSD storage types
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Base ¶
type Base struct {
// contains filtered or unexported fields
}
Base provides a quick way to comply with the Model interface.
func (*Base) CreateMeta ¶
func (b *Base) CreateMeta()
CreateMeta sets a default metadata object for this record.
func (*Base) DatabaseKey ¶
DatabaseKey returns the database key of the database record. As the key must be set before any usage and can only be set once, this function may be used without locking the record.
func (*Base) DatabaseName ¶
DatabaseName returns the name of the database. As the key must be set before any usage and can only be set once, this function may be used without locking the record.
func (*Base) GetAccessor ¶
GetAccessor returns an accessor for this record, if available.
func (*Base) Key ¶
Key returns the key of the database record. As the key must be set before any usage and can only be set once, this function may be used without locking the record.
func (*Base) KeyIsSet ¶
KeyIsSet returns true if the database key is set. As the key must be set before any usage and can only be set once, this function may be used without locking the record.
func (*Base) Marshal ¶
Marshal marshals the object, without the database key or metadata. It returns nil if the record is deleted.
func (*Base) MarshalRecord ¶
MarshalRecord packs the object, including metadata, into a byte array for saving in a database.
func (*Base) SetKey ¶
SetKey sets the key on the database record. The key may only be set once and future calls to SetKey will be ignored. If you want to copy/move the record to another database key, you will need to create a copy and assign a new key. A key must be set before the record is used in any database operation.
func (*Base) SetMeta ¶
SetMeta sets the metadata on the database record, it should only be called after loading the record. Use MoveTo to save the record with another key.
func (*Base) UpdateMeta ¶
func (b *Base) UpdateMeta()
UpdateMeta creates the metadata if it does not exist and updates it.
type Meta ¶
type Meta struct { Created int64 Modified int64 Expires int64 Deleted int64 // contains filtered or unexported fields }
Meta holds
func (*Meta) CheckPermission ¶
CheckPermission checks whether the database record may be accessed with the following scope.
func (*Meta) CheckValidity ¶
CheckValidity checks whether the database record is valid.
func (*Meta) GenCodeMarshal ¶
GenCodeMarshal gencode marshalls Meta into the given byte array, or a new one if its too small.
func (*Meta) GenCodeSize ¶
GenCodeSize returns the size of the gencode marshalled byte slice
func (*Meta) GenCodeUnmarshal ¶
GenCodeUnmarshal gencode unmarshalls Meta and returns the bytes read.
func (*Meta) GetAbsoluteExpiry ¶
GetAbsoluteExpiry returns the absolute expiry time.
func (*Meta) GetRelativeExpiry ¶
GetRelativeExpiry returns the current relative expiry time - ie. seconds until expiry. A negative value signifies that the record does not expire.
func (*Meta) MakeCrownJewel ¶
func (m *Meta) MakeCrownJewel()
MakeCrownJewel marks the database records as a crownjewel, meaning that it will not be sent/synced to other devices.
func (*Meta) MakeSecret ¶
func (m *Meta) MakeSecret()
MakeSecret sets the database record as secret, meaning that it may only be used internally, and not by interfacing processes, such as the UI.
func (*Meta) Reset ¶
func (m *Meta) Reset()
Reset resets all metadata, except for the secret and crownjewel status.
func (*Meta) SetAbsoluteExpiry ¶
SetAbsoluteExpiry sets an absolute expiry time (in seconds), that is not affected when the record is updated.
func (*Meta) SetRelativateExpiry ¶
SetRelativateExpiry sets a relative expiry time (ie. TTL in seconds) that is automatically updated whenever the record is updated/saved.
type Record ¶
type Record interface { SetKey(key string) // test:config Key() string // test:config KeyIsSet() bool DatabaseName() string // test DatabaseKey() string // config Meta() *Meta SetMeta(meta *Meta) CreateMeta() UpdateMeta() Marshal(self Record, format uint8) ([]byte, error) MarshalRecord(self Record) ([]byte, error) GetAccessor(self Record) accessor.Accessor Lock() Unlock() IsWrapped() bool }
Record provides an interface for uniformally handling database records.
type Wrapper ¶
Wrapper wraps raw data and implements the Record interface.
func NewRawWrapper ¶
NewRawWrapper returns a record wrapper for the given data, including metadata. This is normally only used by storage backends when loading records.
func NewWrapper ¶
NewWrapper returns a new record wrapper for the given data.
func (*Wrapper) GetAccessor ¶
GetAccessor returns an accessor for this record, if available.