document

package
v0.0.0-...-65ae5a0 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Document

type Document struct {
	ID         ulid.ULID              `json:"_id"`
	Collection string                 `json:"collection"`
	Data       map[string]interface{} `json:"data"`
}

Document is a document that can be stored in a database.

func FromStorage

func FromStorage(b []byte, encryptionKey []byte) (*Document, error)

FromStorage returns a document from a byte slice that was stored in a database, if an encryption key is provided, the document will be decrypted.

func New

func New() *Document

New returns a new document.

func (*Document) SetCollection

func (d *Document) SetCollection(name string) *Document

SetCollection sets the collection of the document.

func (*Document) SetData

func (d *Document) SetData(data map[string]interface{}) *Document

SetData sets the fields of the document.

func (*Document) SetID

func (d *Document) SetID(id string) *Document

SetID sets the ID of the document. Should only be used for testing.

func (*Document) ToStorage

func (d *Document) ToStorage(encryptionKey []byte) ([]byte, error)

ToStorage returns the document as a byte slice that can be stored in a database, if an encryption key is provided, the document will be encrypted.

Jump to

Keyboard shortcuts

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