docstore

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2020 License: MIT Imports: 4 Imported by: 0

README

docstore is a package that stores revisioned documents.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateDocId

func ValidateDocId(docId string) error

ValidateDocId returns an error if the docId doesn't match the validDocRegex

Types

type Doc

type Doc struct {
	Id             string
	LatestRevision int
}

type DocPage

type DocPage struct {
	Docs      []Doc
	NextToken string
	More      bool // True if there are more docs
}

type DocStore

type DocStore interface {
	GetDoc(docId string) (rev Revision, err error)                      // Get the latest revision of a document
	GetRevision(docId string, revisionId int) (rev Revision, err error) // Get a specific revision of a document
	PutRevision(docId string, body io.Reader) (rev Revision, err error) // Put a new revision of a document. It will make a new doc if the DocId doesn't exist.
	ListDocs(token string) (page DocPage, err error)                    // List all the docs
	ListRevisions(docId string, token string) (RevisionPage, error)     // List all the revisions for a doc
}

type Revision

type Revision interface {
	Metadata() RevisionMetadata
	Read(p []byte) (n int, err error)
}

type RevisionMetadata

type RevisionMetadata struct {
	DocId     string
	Id        int
	Timestamp time.Time
}

type RevisionPage

type RevisionPage struct {
	Revisions []RevisionMetadata
	NextToken string
	More      bool // True if there are more revisions
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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