Documentation
¶
Overview ¶
Package store - Contains solutions for Reading/Writing leaps documents, all store types should implement the Storage interface as this is used by leaps to read and write documents.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrMissingDSN = errors.New("Missing DSN") ErrUnrecognizedSQLType = errors.New("SQL Type not recognized") )
SQL Type errors.
var (
ErrDocumentNotExist = errors.New("attempted to fetch memory doc that has not been initialized")
)
Errors for the Memory type.
var (
ErrInvalidDirectory = errors.New("invalid directory")
)
Errors for the FileStore type.
Functions ¶
This section is empty.
Types ¶
type Document ¶
type Document struct { ID string `json:"id" yaml:"id"` Content string `json:"content" yaml:"content"` }
Document - A representation of a leap document, must have a unique ID.
func NewDocument ¶
NewDocument - Create a document with content and a generated UUID.
type File ¶
type File struct {
// contains filtered or unexported fields
}
File - Most basic persistent implementation of store.Crud. Simply stores each document into a file within a configured directory. The ID represents the filepath relative to the configured directory.
For example, with StoreDirectory set to /var/www, a document can be given the ID css/main.css to create and edit the file /var/www/css/main.css
type Memory ¶
type Memory struct {
// contains filtered or unexported fields
}
Memory - Simply keeps documents in memory. Has zero persistence across sessions.
type SQL ¶
type SQL struct {
// contains filtered or unexported fields
}
SQL - A document store implementation for an SQL database.
type SQLConfig ¶
type SQLConfig struct { DSN string `json:"dsn" yaml:"dsn"` TableConfig TableConfig `json:"db_table" yaml:"db_table"` }
SQLConfig - The configuration fields for an SQL document store solution.
type TableConfig ¶
type TableConfig struct { Name string `json:"table" yaml:"table"` IDCol string `json:"id_column" yaml:"id_column"` ContentCol string `json:"content_column" yaml:"content_column"` }
TableConfig - Fields for specifying the table labels of the SQL database target.
func NewTableConfig ¶
func NewTableConfig() TableConfig
NewTableConfig - Default table configuration.
type Type ¶
type Type interface { // Create - Create a new document. Create(Document) error // Read - Read a document. Read(ID string) (Document, error) // Update - Update an existing document. Update(Document) error }
Type - Implemented by types able to acquire and store documents. This is abstracted in order to accommodate for multiple storage strategies. These methods should be asynchronous if possible.
func NewMySQL ¶
NewMySQL - Returns an SQL store type for connecting to MySQL databases.
DSN Should be of the format: [username[:password]@][protocol[(address)]]/dbname[?param1=value1&...¶mN=valueN]
func NewPostgreSQL ¶
NewPostgreSQL - Returns an SQL store type for connecting to PostgreSQL databases.
DSN Should be of the format: postgresql://[user[:password]@][netloc][:port][/dbname][?param1=value1&...]