api

package
v0.0.0-...-163263d Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NextID

func NextID() string

NextID generates a pseudo-random ID that could be used when creating a document

Types

type Authenticator

type Authenticator interface {
	Authenticate(r *http.Request) (User, error)
}

Authenticator describes the interface that a service authenticating an HTTP request should implement

type Cacheable

type Cacheable interface {
	GetLastModified() time.Time
}

type Collection

type Collection struct {
	ID       string     `json:"id"`
	Features []Document `json:"features"`
}

Collection represents a list of documents

type Cursor

type Cursor interface {
	Fetch(count int) ([]Document, error)
	Close() error
}

type Document

type Document struct {
	ID                   string                 `json:"id"`
	CreationDate         time.Time              `json:"creationDate,omitempty"`
	LastModificationDate time.Time              `json:"lastModificationDate,omitempty"`
	Properties           map[string]interface{} `json:"properties"`
}

Document represents a document in a collection

func (Document) GetLastModified

func (d Document) GetLastModified() time.Time

type DocumentProperties

type DocumentProperties map[string]interface{}

DocumentProperties represents the properties of the document

type ObjectRef

type ObjectRef []string

func (ObjectRef) Collection

func (d ObjectRef) Collection() ObjectRef

func (ObjectRef) ID

func (o ObjectRef) ID() string

func (ObjectRef) IsDocument

func (o ObjectRef) IsDocument() bool

func (ObjectRef) String

func (c ObjectRef) String() string

type Repository

type Repository interface {
	Init() error

	Begin() (Transaction, error)
}

Repository describes the interface that a datastore should implement

type Transaction

type Transaction interface {
	Get(document ObjectRef) (Document, error)
	GetAll(collection ObjectRef, orderBy []string) (Cursor, error)
	Add(collection ObjectRef, payload DocumentProperties) (Document, error)
	Put(document ObjectRef, payload DocumentProperties) error
	Patch(document ObjectRef, payload DocumentProperties) error
	Delete(document ObjectRef) error
	DeleteCollection(collection ObjectRef) error

	Commit() error
	Rollback() error
}

Transaction describes the interface that a datastore transaction should implement

type User

type User struct {
	ID    string
	Name  string
	Email string
}

User contains the details about the user inetrracting with the app

Jump to

Keyboard shortcuts

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