Documentation
¶
Overview ¶
Package memdocstore provides an in-memory implementation of the docstore API. It is suitable for local development and testing.
Every document in a memdocstore collection has a unique primary key. The primary key values need not be strings; they may be any comparable Go value.
Unordered Action Lists ¶
Unordered action lists are executed concurrently. Each action in an unordered action list is executed in a separate goroutine.
URLs ¶
For docstore.OpenCollection, memdocstore registers for the scheme "mem". To customize the URL opener, or for more details on the URL format, see URLOpener. See https://github.com/eliben/gocdkx/concepts/urls/ for background information.
Index ¶
Constants ¶
const Scheme = "mem"
Scheme is the URL scheme memdocstore registers its URLOpener under on docstore.DefaultMux.
Variables ¶
This section is empty.
Functions ¶
func OpenCollection ¶
func OpenCollection(keyField string, _ *Options) (*docstore.Collection, error)
OpenCollection creates a *docstore.Collection backed by memory. keyField is the document field holding the primary key of the collection.
func OpenCollectionWithKeyFunc ¶
func OpenCollectionWithKeyFunc(keyFunc func(docstore.Document) interface{}, _ *Options) (*docstore.Collection, error)
OpenCollectionWithKeyFunc creates a *docstore.Collection backed by memory. keyFunc takes a document and returns the document's primary key. It should return nil if the document is missing the information to construct a key. This will cause all actions, even Create, to fail.
Types ¶
type Options ¶
type Options struct{}
Options are optional arguments to the OpenCollection functions.
type URLOpener ¶
type URLOpener struct{}
URLOpener opens URLs like "mem://_id".
The URL's host is used as the keyField. The URL's path is ignored.
No query parameters are supported.
func (*URLOpener) OpenCollectionURL ¶
OpenCollectionURL opens a docstore.Collection based on u.