datastore

package module
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const AfterInsert = "aINSERT"
View Source
const AfterSelect = "aSELECT"
View Source
const BeforeInsert = "bINSERT"
View Source
const BeforeSelect = "bSELECT"

Variables

This section is empty.

Functions

This section is empty.

Types

type Collection

type Collection struct {
	DB        *sqlx.DB
	Table     string
	Callbacks map[string][]func(q *Query)
}

Collection holds a table scoped database connection

func NewCollection added in v0.1.4

func NewCollection(db *sqlx.DB, tableName string) *Collection

func (*Collection) AddCallback added in v0.1.4

func (c *Collection) AddCallback(key string, cb func(q *Query))

func (*Collection) Find

func (c *Collection) Find(Criteria M) *Query

func (*Collection) FindOne

func (c *Collection) FindOne(Criteria M) *Query

func (*Collection) Insert

func (c *Collection) Insert(from M) *Query

func (*Collection) Truncate

func (c *Collection) Truncate() error

type M

type M map[string]interface{}

M is a map

type Query

type Query struct {
	C *Collection

	Criteria M

	LastID int
	Err    error
	// contains filtered or unexported fields
}

func (*Query) GetLastID

func (q *Query) GetLastID() int

func (*Query) Limit

func (q *Query) Limit(n int) *Query

func (*Query) Order

func (q *Query) Order(by []string) *Query

func (*Query) Run

func (q *Query) Run(dest interface{}) error

type Store

type Store struct {
	DB          *sqlx.DB
	Collections map[string]*Collection
}

Store holds all database collections

func NewConnection

func NewConnection(uri string, seed func(db *sqlx.DB) error) (*Store, error)

NewConnection creates a sql database connection and contentful client

func (*Store) AddCollection

func (s *Store) AddCollection(tableName string) *Collection

Jump to

Keyboard shortcuts

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