document

package
v0.0.0-...-c1dc28d Latest Latest
Warning

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

Go to latest
Published: May 28, 2019 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package document contains structures for representing the documents stored in a Protavo database.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetStringContent

func GetStringContent(m proto.Message) string

GetStringContent returns the string value of a message created with StringContent().

func StringContent

func StringContent(s string) proto.Message

StringContent is a convenience function that returns a Protocol Buffers message that contains a single string.

It be used to easily store plain string content inside a document. The string can be retreived with GetStringContent().

Types

type Document

type Document struct {
	// ID is the document's unique identifier. It can be any non-empty string.
	ID string

	// Keys is the set of indexing keys applied to the document. Keys are used
	// to quickly find a document or set of documents based on identifiers
	// other than the document ID.
	Keys Keys

	// Headers is an arbitrary set of key/value pairs that is persisted along
	// with the document content.
	Headers Headers

	// Content is the application-defined document content.
	Content proto.Message

	// Revision is the version of the document as represented by this value.
	// When modifying a document, it must be equal to the revision of the document
	// that is currently persisted, otherwise an OptimisticLockError occurs.
	Revision uint64

	// CreatedAt is the time at which the document was created. The value is
	// set automatically when the document is saved for the first time.
	CreatedAt time.Time

	// UpdatedAt is the time at which the document was last modified. The value
	// is set automatically when the document is saved.
	UpdatedAt time.Time
}

Document is a document stored in a DB.

func (*Document) Equal

func (d *Document) Equal(doc *Document) bool

Equal returns true if d and doc are equal.

func (*Document) KeysByType

func (d *Document) KeysByType(t KeyType) []string

KeysByType returns the subset of the document's keys that are of the given type.

func (*Document) SharedKeys

func (d *Document) SharedKeys() []string

SharedKeys returns the document's shared indexing keys.

func (*Document) UniqueKeys

func (d *Document) UniqueKeys() []string

UniqueKeys returns the document's unique indexing keys.

func (*Document) Validate

func (d *Document) Validate()

Validate panics if the document is not valid.

type Headers

type Headers map[string]string

Headers is a map of header name to value.

type KeyType

type KeyType int32

KeyType is an enumeration of the different types of document keys.

const (
	// UniqueKey is the KeyType for keys that are always exclusive to a single document.
	// Uniqye keys are useful for addressing specific documents by some role they
	// fill or property they hold.
	UniqueKey KeyType = 1

	// SharedKey is the KeyType for keys that may be shared by multiple documents.
	// Shared keys are useful for quickly locating sets of related documents.
	SharedKey KeyType = 2
)

type Keys

type Keys map[string]KeyType

Keys is a map of key name to type.

func SharedKeys

func SharedKeys(keys ...string) Keys

SharedKeys is a convenience function for creating a key-map consisting of a set of shared keys.

func UniqueKeys

func UniqueKeys(keys ...string) Keys

UniqueKeys is a convenience function for creating a key-map consisting of a set of unique keys.

type StringContentType

type StringContentType struct {
	Value                string   `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*StringContentType) Descriptor

func (*StringContentType) Descriptor() ([]byte, []int)

func (*StringContentType) GetValue

func (m *StringContentType) GetValue() string

func (*StringContentType) ProtoMessage

func (*StringContentType) ProtoMessage()

func (*StringContentType) Reset

func (m *StringContentType) Reset()

func (*StringContentType) String

func (m *StringContentType) String() string

func (*StringContentType) XXX_DiscardUnknown

func (m *StringContentType) XXX_DiscardUnknown()

func (*StringContentType) XXX_Marshal

func (m *StringContentType) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*StringContentType) XXX_Merge

func (dst *StringContentType) XXX_Merge(src proto.Message)

func (*StringContentType) XXX_Size

func (m *StringContentType) XXX_Size() int

func (*StringContentType) XXX_Unmarshal

func (m *StringContentType) XXX_Unmarshal(b []byte) error

Jump to

Keyboard shortcuts

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