skdb

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2024 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(name string, open func(uri string) (Repository, error))

Register makes a repository driver available by the provided name.

If Register is called twice with the same name or if open is nil, it panics.

Types

type Repository

type Repository interface {
	Name() string

	NumUsers(ctx context.Context) (int64, error)
	Users(ctx context.Context) iter.Seq2[sako.User, error]
	GetUser(ctx context.Context, name string) (sako.User, error)
	AddUser(ctx context.Context, usr sako.User, pwd string) (sako.User, error)
	DelUser(ctx context.Context, uid sako.UserID) error

	NumEntries(ctx context.Context, uid sako.UserID, opts ...sako.FilterOptions) (int64, error)
	Entries(ctx context.Context, uid sako.UserID, opts ...sako.FilterOptions) iter.Seq2[sako.Entry, error]
	GetEntry(ctx context.Context, id sako.EntryID) (sako.Entry, error)
	AddEntry(ctx context.Context, e sako.Entry) (sako.Entry, error)
	PutEntry(ctx context.Context, e sako.Entry) error
	HasEntry(ctx context.Context, uid sako.UserID, hashURL string) (sako.EntryID, error)
	DelEntry(ctx context.Context, uid sako.UserID, id sako.EntryID) error

	NumTags(ctx context.Context, uid sako.UserID) (int64, error)
	Tags(ctx context.Context, uid sako.UserID) iter.Seq2[sako.Tag, error]
	GetTags(ctx context.Context, uid sako.UserID, id sako.EntryID) iter.Seq2[sako.Tag, error]
	AddTags(ctx context.Context, uid sako.UserID, id sako.EntryID, tags ...string) error
	DelTags(ctx context.Context, uid sako.UserID, id sako.EntryID, tags ...sako.TagID) error

	NumAnnotations(ctx context.Context, id sako.EntryID) (int64, error)
	Annotations(ctx context.Context, id sako.EntryID) iter.Seq2[sako.Annotation, error]
	GetAnnotation(ctx context.Context, id sako.AnnotationID) (sako.Annotation, error)
	AddAnnotation(ctx context.Context, id sako.EntryID, ann sako.Annotation) error
	DelAnnotation(ctx context.Context, id sako.AnnotationID) error

	GetTaggingRules(ctx context.Context, uid sako.UserID) ([]sako.TaggingRule, error)
	AddTaggingRules(ctx context.Context, uid sako.UserID, rules []sako.TaggingRule) error
	PutTaggingRule(ctx context.Context, uid sako.UserID, rule sako.TaggingRule) error

	NumSearch(ctx context.Context, uid sako.UserID, opts ...sako.SearchOptions) (int64, error)
	Search(ctx context.Context, uid sako.UserID, opts ...sako.SearchOptions) iter.Seq2[sako.Entry, error]

	Do(ctx context.Context, f func(tx *sql.Tx) error) error

	io.Closer
}

Repository represents the operations available on a sako repository of articles.

func Open

func Open(uri string) (Repository, error)

Open opens a repository via an already registered repository driver.

Directories

Path Synopsis
Package sqlite implements a sako repository backed by a SQLite database.
Package sqlite implements a sako repository backed by a SQLite database.

Jump to

Keyboard shortcuts

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