journal

package
v0.15.1 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2022 License: Apache-2.0 Imports: 2 Imported by: 3

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  `json:"createDate" bson:"createDate"`
	UpdateDate int64  `json:"updateDate" bson:"updateDate"`
	DeleteDate int64  `json:"deleteDate" bson:"deleteDate"`
	Note       string `json:"note"       bson:"note"`
	Revision   int64  `json:"signature"  bson:"signature"`
}

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 time 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 time 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