driver

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Driver

type Driver struct {
	// contains filtered or unexported fields
}

func NewDirectoryDriver added in v0.0.2

func NewDirectoryDriver(db *sql.DB, opts ...Options) *Driver

func (*Driver) CreateDirectory

func (t *Driver) CreateDirectory(ctx context.Context, d *v1.Directory) (*v1.Directory, error)

CreateDirectory creates the provided directory.

func (*Driver) CreateRoot

func (t *Driver) CreateRoot(ctx context.Context, d *v1.Directory) (*v1.Directory, error)

CreateRoot creates a root directory. Root directories are directories that have no parent directory. ID is generated by the database, it will be ignored if given.

func (*Driver) DeleteDirectory added in v0.0.4

func (t *Driver) DeleteDirectory(ctx context.Context, id v1.DirectoryID) ([]*v1.Directory, error)

DeleteDirectory soft deletes the provided directory id. If the provided directory has children, all child directories are soft deleted as well.

func (*Driver) GetChildren

func (t *Driver) GetChildren(
	ctx context.Context,
	parent v1.DirectoryID,
	options ...storage.Option,
) ([]v1.DirectoryID, error)

GetChildren returns all children of the provided directory.

func (*Driver) GetDirectory

func (t *Driver) GetDirectory(
	ctx context.Context,
	id v1.DirectoryID,
	options ...storage.Option,
) (*v1.Directory, error)

GetDirectoryByID returns a directory by its ID. Note that this call does not give out parent information.

func (*Driver) GetParents

func (t *Driver) GetParents(
	ctx context.Context,
	child v1.DirectoryID,
	options ...storage.Option,
) ([]v1.DirectoryID, error)

GetParents returns all ids for each parent directory of the provided child id.

func (*Driver) GetParentsUntilAncestor

func (t *Driver) GetParentsUntilAncestor(
	ctx context.Context,
	child, ancestor v1.DirectoryID,
	options ...storage.Option,
) ([]v1.DirectoryID, error)

GetParentsUntilAncestor returns all ids for each parent directory for the provided child until the provided ancestor is reached.

func (*Driver) ListRoots

func (t *Driver) ListRoots(ctx context.Context, options ...storage.Option) ([]v1.DirectoryID, error)

ListRoots returns all root directory ids.

func (*Driver) UpdateDirectory added in v0.0.13

func (t *Driver) UpdateDirectory(ctx context.Context, d *v1.Directory) error

UpdateDirectory updates the directory.

type Options added in v0.0.2

type Options func(*Driver)

Options defines ways to configure the CRDB driver.

func WithFastReads added in v0.0.2

func WithFastReads() Options

WithFastReads configures the driver to use fast reads. This is useful for read-only drivers. It will use a different query to read directories, which relies on follower reads. It is important to note that this query will not return the latest data, but it will return data that is consistent with the latest data.

func WithReadOnly added in v0.0.2

func WithReadOnly() Options

WithReadOnly configures the driver to be read-only.

Jump to

Keyboard shortcuts

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