Documentation
¶
Index ¶
Constants ¶
const ( // Precision is the effective precision of timestamps. // Currently it's 1 microsecond as it's what Datastore supports. // Datastore: 1 microsecond: https://cloud.google.com/datastore/docs/concepts/entities#date_and_time Precision = time.Microsecond )
Variables ¶
This section is empty.
Functions ¶
func TimeToProto ¶
func TimeToProto(t time.Time) *timestamppb.Timestamp
TimeToProto converts time.Time to timestamppb.Timestamp. If t is zero, it returns nil.
Types ¶
type Timestamps ¶
type Timestamps struct { // CreatedAt is the timestamp of the record creation time // Automatically set by MetaDB CreatedAt time.Time `datastore:",noindex"` // UpdatedAt is the timestamp of the last modification time // Automatically set and managed by MetaDB UpdatedAt time.Time `datastore:",noindex"` // Signature is a UUID that is randomly created each time the record is updated // Automatically set and managed by MetaDB Signature uuid.UUID `datastore:"-"` }
Timestamps keeps keeps when each record is created or updated as well as a randomly generated UUID to keep consistency under concurrent writes. It should be embedded to metadata entities such as Record and Store.
func New ¶
func New() Timestamps
New returns a new Timestamps instance with CreatedAt and UpdatedAt set to time.Now() and Signature set to uuid.New().
func (*Timestamps) Load ¶
func (t *Timestamps) Load(ps []datastore.Property) error
Load implements the Datastore PropertyLoadSaver interface and converts Datastore properties to corresponding struct fields.
func (*Timestamps) Save ¶
func (t *Timestamps) Save() ([]datastore.Property, error)
Save implements the Datastore PropertyLoadSaver interface and converts the properties field in the struct to separate Datastore properties.
func (*Timestamps) Update ¶
func (t *Timestamps) Update()
Update updates the UpdatedAt and Signature fields with time.Now() and uuid.New().