Documentation ¶
Index ¶
- Constants
- func BuildCollectionNode() (datamodel.Node, error)
- func BuildRootCollectionsNode(ctx context.Context, store *Store, s *ast.Schema) (datamodel.Node, error)
- func BuildRootNode(ctx context.Context, store *Store, schema string) (datamodel.Node, error)
- func BuildRootParentsNode(parents ...datamodel.Link) (datamodel.Node, error)
- func CollectionPath(collection string) datamodel.Path
- func DocumentPath(collection string, id string) datamodel.Path
- func DocumentsPath(collection string) datamodel.Path
- func Dump(ctx context.Context, store *Store, rootLink datamodel.Link) (map[string][]string, error)
- func Export(ctx context.Context, store *Store, rootLink datamodel.Link, out io.Writer) error
- func Independents(ctx context.Context, store *Store, links []datamodel.Link) ([]datamodel.Link, error)
- func IsAncestor(ctx context.Context, store *Store, oldLink, newLink datamodel.Link) (bool, error)
- func MergeBase(ctx context.Context, store *Store, oldLink, newLink datamodel.Link) ([]datamodel.Link, error)
- type DocumentIterator
- type ParentIterator
- type Store
- func (s *Store) GetNode(ctx context.Context, path datamodel.Path, node datamodel.Node) (datamodel.Node, error)
- func (s *Store) Load(ctx context.Context, lnk datamodel.Link, np datamodel.NodePrototype) (datamodel.Node, error)
- func (s *Store) ParentIterator(rootLink datamodel.Link) *ParentIterator
- func (s *Store) SetNode(ctx context.Context, path datamodel.Path, node datamodel.Node, ...) (datamodel.Node, error)
- func (s *Store) Store(ctx context.Context, node datamodel.Node) (datamodel.Link, error)
- func (s *Store) Traversal(ctx context.Context) traversal.Progress
- type Transaction
- func (t *Transaction) Commit(ctx context.Context) (datamodel.Link, error)
- func (t *Transaction) CreateDocument(ctx context.Context, collection string, value map[string]any) (string, error)
- func (t *Transaction) DeleteDocument(ctx context.Context, collection, id string) error
- func (t *Transaction) DocumentIterator(ctx context.Context, collection string) (*DocumentIterator, error)
- func (t *Transaction) PatchDocument(ctx context.Context, collection, id string, value map[string]any) error
- func (t *Transaction) ReadDocument(ctx context.Context, collection, id string) (datamodel.Node, error)
Constants ¶
const ( // RootParentsFieldName is the name of the parents field on a root. RootParentsFieldName = "Parents" // RootSchemaFieldName is the name of the schema field on a root. RootSchemaFieldName = "Schema" // RootCollectionsFieldName is the name of the collections field on a root. RootCollectionsFieldName = "Collections" // CollectionDocumentsFieldName is the name of the documents field on a collection. CollectionDocumentsFieldName = "Documents" )
Variables ¶
This section is empty.
Functions ¶
func BuildCollectionNode ¶
BuildCollectionNode returns a new collection node with default field values.
func BuildRootCollectionsNode ¶
func BuildRootCollectionsNode(ctx context.Context, store *Store, s *ast.Schema) (datamodel.Node, error)
BuildRootCollectionsNode returns a new collections field node containing the collections defined in the given schema.
func BuildRootNode ¶
BuildRootNode returns a new root node with the collections defined in the given schema.
func BuildRootParentsNode ¶
BuildRoootParentsNode returns a new parents field node node containing the given parent links.
func CollectionPath ¶
CollectionPath returns the path for the given collection.
func DocumentPath ¶
DocumentPath returns the path for the document in the given collection with the given id.
func DocumentsPath ¶
DocumentsPath returns the path for the documents map of the given collection.
func Dump ¶
Dump returns a map of collections to document ids.
This function is primarily used for testing.
func Export ¶
Export writes a CAR containing the DAG starting from the given root link to the given io.Writer.
func Independents ¶
func Independents(ctx context.Context, store *Store, links []datamodel.Link) ([]datamodel.Link, error)
Independents returns a list links where each entry is not an ancestor of any other entry.
func IsAncestor ¶
IsAncestor returns true if the old link is an ancestor of the new link.
Types ¶
type DocumentIterator ¶
type DocumentIterator struct {
// contains filtered or unexported fields
}
DocumentIterator iterates over all documents in a collection.
func (*DocumentIterator) Done ¶
func (i *DocumentIterator) Done() bool
Done returns true if the iterator has no items left.
type ParentIterator ¶
type ParentIterator struct {
// contains filtered or unexported fields
}
ParentIterator iterates over all parents of a root node.
func (*ParentIterator) Done ¶
func (i *ParentIterator) Done() bool
Done returns true if the iterator has no items left.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is a content addressable data store.
func NewStore ¶
NewStore returns a new Store that uses the given storage to read and write content addressable data.
func (*Store) GetNode ¶
func (s *Store) GetNode(ctx context.Context, path datamodel.Path, node datamodel.Node) (datamodel.Node, error)
GetNode returns the node at the given path starting from the given node.
func (*Store) Load ¶
func (s *Store) Load(ctx context.Context, lnk datamodel.Link, np datamodel.NodePrototype) (datamodel.Node, error)
Load returns the node matching the given link and built using the given prototype.
func (*Store) ParentIterator ¶
func (s *Store) ParentIterator(rootLink datamodel.Link) *ParentIterator
ParentIterator returns a new iterator that can be used to iterate through all parents of a root node.
func (*Store) SetNode ¶
func (s *Store) SetNode(ctx context.Context, path datamodel.Path, node datamodel.Node, value datamodel.Node) (datamodel.Node, error)
SetNode sets the node at the given path starting from the given node returning the updated node.
type Transaction ¶
type Transaction struct {
// contains filtered or unexported fields
}
Transaction is used to create, read, update, and delete documents.
func NewTransaction ¶
func NewTransaction(ctx context.Context, store *Store, schema *ast.Schema, rootLink datamodel.Link) (*Transaction, error)
NewTransaction creates a new transaction using the given store, schema, and root link.
func (*Transaction) Commit ¶
Commit creates a new root node containing the mutations that were applied during the lifetime of this transaction.
func (*Transaction) CreateDocument ¶
func (t *Transaction) CreateDocument(ctx context.Context, collection string, value map[string]any) (string, error)
CreateDocument creates a document in the given collection using the given value and returns its unique id.
func (*Transaction) DeleteDocument ¶
func (t *Transaction) DeleteDocument(ctx context.Context, collection, id string) error
DeleteDocument deletes the document in the given collection with the given id.
func (*Transaction) DocumentIterator ¶
func (t *Transaction) DocumentIterator(ctx context.Context, collection string) (*DocumentIterator, error)
DocumentIterator returns a new iterator that can be used to iterate through all documents in a collection.
func (*Transaction) PatchDocument ¶
func (t *Transaction) PatchDocument(ctx context.Context, collection, id string, value map[string]any) error
PatchDocument patches the document in the given collection with the given id by applying the operations in the given value.
func (*Transaction) ReadDocument ¶
func (t *Transaction) ReadDocument(ctx context.Context, collection, id string) (datamodel.Node, error)
ReadDocument returns the document in the given collection with the given id.