Documentation
¶
Overview ¶
Package memory is an in-process docstore.Store backed by maps. It is meant for tests, `backyard dev` and single-instance demos: data is lost when the process exits.
Stored documents are immutable values (writes replace them), and data is deep-copied on the way in and out, so callers never alias internal state. Queries are evaluated with the reference implementation in package docstore (docstore.EvalQuery).
Index ¶
- Variables
- type Store
- func (s *Store) Close() error
- func (s *Store) Collections(ctx context.Context, site string) ([]string, error)
- func (s *Store) Count(ctx context.Context, site string) (int64, error)
- func (s *Store) Create(ctx context.Context, site, collection, id string, data map[string]any, ...) (*docstore.Doc, error)
- func (s *Store) Delete(ctx context.Context, site, collection, id string) (bool, error)
- func (s *Store) DeleteIf(ctx context.Context, site, collection, id string, rev docstore.Rev) (bool, error)
- func (s *Store) DeleteSite(ctx context.Context, site string) error
- func (s *Store) Get(ctx context.Context, site, collection, id string) (*docstore.Doc, error)
- func (s *Store) Ping(ctx context.Context) error
- func (s *Store) Put(ctx context.Context, site, collection, id string, data map[string]any, ...) (*docstore.Doc, error)
- func (s *Store) Query(ctx context.Context, site, collection string, q docstore.Query) (*docstore.Page, error)
- func (s *Store) Update(ctx context.Context, site, collection, id string, patch map[string]any, ...) (*docstore.Doc, error)
- func (s *Store) UpdateIf(ctx context.Context, site, collection, id string, rev docstore.Rev, ...) (*docstore.Doc, error)
Constants ¶
This section is empty.
Variables ¶
var ErrClosed = errors.New("docstore/memory: store closed")
ErrClosed is returned by operations on a closed store.
Functions ¶
This section is empty.
Types ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is an in-memory document store. The zero value is not usable; call New.
func (*Store) Collections ¶
Collections lists the non-empty collections of a site, sorted.
func (*Store) Create ¶
func (s *Store) Create(ctx context.Context, site, collection, id string, data map[string]any, actor string) (*docstore.Doc, error)
Create inserts a new document; see docstore.Store.
func (*Store) DeleteIf ¶ added in v0.2.0
func (s *Store) DeleteIf(ctx context.Context, site, collection, id string, rev docstore.Rev) (bool, error)
DeleteIf removes a document while it is at rev; see docstore.Store.
func (*Store) DeleteSite ¶
DeleteSite removes every document of a site.
func (*Store) Put ¶
func (s *Store) Put(ctx context.Context, site, collection, id string, data map[string]any, actor string) (*docstore.Doc, error)
Put creates or replaces a document; see docstore.Store.
func (*Store) Query ¶
func (s *Store) Query(ctx context.Context, site, collection string, q docstore.Query) (*docstore.Page, error)
Query returns matching documents; see docstore.Store.