journal

package
v0.28.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 22, 2024 License: Apache-2.0 Imports: 2 Imported by: 2

README

Journal

This package provides most of the data and features required by the data.Object interface.


// Here's a simple definition for a person object
type Person struct {
    PersonID string
    Name     string
    Email    string

    journal.Journal  // Include this line here for all data tracking info.
}

// ID is the only field that you need to define separately from the Journal, 
//in order to make this fit the data.Object interface
func (person *Person) ID() string {
    return person.PersonID
}

// journal.Journal defines all of the other data points and methods required 
// to meet the data.Object interface

// IsNew() bool
// SetCreated(string)
// SetUpdated(string)
// SetDeleted(string)

Pull Requests Welcome

This library is a work in progress, and will benefit from your experience reports, use cases, and contributions. If you have an idea for making this library better, send in a pull request. We're all in this together! 📚

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Journal

type Journal struct {
	CreateDate int64  `path:"createDate" json:"createDate" bson:"createDate"` // CreateDate is the Unix epoch (milliseconds) that the attached object was created
	UpdateDate int64  `path:"updateDate" json:"updateDate" bson:"updateDate"` // UpdateDate is the Unix epoch (milliseconds) that the attached object was last updated
	DeleteDate int64  `path:"deleteDate" json:"deleteDate" bson:"deleteDate"` // DeleteDate is the Unix epoch (milliseconds) that the attached object was deleted
	Note       string `path:"note"       json:"note"       bson:"note"`       // Note is a human-readable description of the change that was made
	Revision   int64  `path:"signature"  json:"signature"  bson:"signature"`  // Signature is a unique identifier for this version of the object
}

Journal tracks a summary of changes to an object over time. Journal implements *most* of the data.Object interface (except for the ID function) right out of the box, so it's a useful example for implementing the data.Object interface, or even to embed directly into an existing model object.

func (Journal) Created added in v0.15.1

func (journal Journal) Created() int64

Created returns the Unix epoch (in milliseconds) when the object containing this journal was created

func (Journal) ETag

func (journal Journal) ETag() string

ETag returns the signature for this object. It currently returns the "revision number" which should be fine unless we make out-of-band updates to objects.

func (Journal) IsDeleted

func (journal Journal) IsDeleted() bool

IsDeleted returns TRUE if the object has been "virtually deleted" from the database

func (Journal) IsNew

func (journal Journal) IsNew() bool

IsNew returns TRUE if the object has not yet been saved to the database

func (*Journal) SetCreated

func (journal *Journal) SetCreated(note string)

SetCreated must be called whenever a new object is added to the database

func (*Journal) SetDeleted

func (journal *Journal) SetDeleted(note string)

SetDeleted must be called to "virtual-delete" an object in the database

func (*Journal) SetUpdated

func (journal *Journal) SetUpdated(note string)

SetUpdated must be called whenever an existing object is updated in the database

func (Journal) Updated added in v0.15.1

func (journal Journal) Updated() int64

Updated returns the Unix epoch (in milliseconds) when the object containing this journal was updated

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL