metadata

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package metadata provides access to SQLite databases and collections information.

Index

Constants

View Source
const (
	// IDColumn is a SQLite path expression for _id field.
	IDColumn = "_ferretdb_sjson->'$._id'"

	// DefaultColumn is a column name for all fields expect _id.
	DefaultColumn = "_ferretdb_sjson"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Collection added in v1.7.0

type Collection struct {
	Name      string
	TableName string
	Settings  []byte
}

Collection represents collection metadata.

type Registry

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

Registry provides access to SQLite databases and collections information.

func NewRegistry

func NewRegistry(u string, l *zap.Logger) (*Registry, error)

NewRegistry creates a registry for SQLite databases in the directory specified by SQLite URI.

func (*Registry) Close

func (r *Registry) Close()

Close closes the registry.

func (*Registry) Collect added in v1.7.0

func (r *Registry) Collect(ch chan<- prometheus.Metric)

Collect implements prometheus.Collector.

func (*Registry) CollectionCreate

func (r *Registry) CollectionCreate(ctx context.Context, dbName string, collectionName string) (bool, error)

CollectionCreate creates a collection in the database.

Returned boolean value indicates whether the collection was created. If collection already exists, (false, nil) is returned.

func (*Registry) CollectionDrop

func (r *Registry) CollectionDrop(ctx context.Context, dbName string, collectionName string) (bool, error)

CollectionDrop drops a collection in the database.

Returned boolean value indicates whether the collection was dropped. If database or collection did not exist, (false, nil) is returned.

func (*Registry) CollectionGet added in v1.7.0

func (r *Registry) CollectionGet(ctx context.Context, dbName string, collectionName string) (*Collection, error)

CollectionGet returns collection metadata.

If database or collection does not exist, (nil, nil) is returned.

func (*Registry) CollectionList

func (r *Registry) CollectionList(ctx context.Context, dbName string) ([]string, error)

CollectionList returns a sorted list of collections in the database.

If database does not exist, no error is returned.

func (*Registry) DatabaseDrop

func (r *Registry) DatabaseDrop(ctx context.Context, dbName string) bool

DatabaseDrop drops the database.

Returned boolean value indicates whether the database was dropped.

func (*Registry) DatabaseGetExisting

func (r *Registry) DatabaseGetExisting(ctx context.Context, dbName string) *fsql.DB

DatabaseGetExisting returns a connection to existing database or nil if it doesn't exist.

func (*Registry) DatabaseGetOrCreate

func (r *Registry) DatabaseGetOrCreate(ctx context.Context, dbName string) (*fsql.DB, error)

DatabaseGetOrCreate returns a connection to existing database or newly created database.

func (*Registry) DatabaseList

func (r *Registry) DatabaseList(ctx context.Context) []string

DatabaseList returns a sorted list of existing databases.

func (*Registry) Describe added in v1.7.0

func (r *Registry) Describe(ch chan<- *prometheus.Desc)

Describe implements prometheus.Collector.

Directories

Path Synopsis
Package pool provides access to SQLite databases and their connections.
Package pool provides access to SQLite databases and their connections.

Jump to

Keyboard shortcuts

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