db

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BadgerDatabase

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

func NewBadger

func NewBadger(dir string) *BadgerDatabase

func (*BadgerDatabase) AddMeta

func (b *BadgerDatabase) AddMeta(id, key string, value interface{}) error

func (*BadgerDatabase) AddMetaBulk

func (b *BadgerDatabase) AddMetaBulk(id string, meta map[string]interface{}) error

func (*BadgerDatabase) AddTag

func (b *BadgerDatabase) AddTag(id, tags string) error

func (*BadgerDatabase) AddTags

func (b *BadgerDatabase) AddTags(id string, tags []string) error

func (*BadgerDatabase) All

func (b *BadgerDatabase) All() ([]*types.Class, error)

func (*BadgerDatabase) Batch

func (b *BadgerDatabase) Batch(ids []string) ([]*types.Class, error)

note: this badger function doesn't use iterators, because deserializing classes from bytes is slow.

func (*BadgerDatabase) Close

func (b *BadgerDatabase) Close() error

func (*BadgerDatabase) Delete

func (b *BadgerDatabase) Delete(id string) error

func (*BadgerDatabase) FindAllTags

func (b *BadgerDatabase) FindAllTags(tags []string) ([]*types.Class, error)

func (*BadgerDatabase) FindAnyTags

func (b *BadgerDatabase) FindAnyTags(tags []string) ([]*types.Class, error)

func (*BadgerDatabase) FindMetaExact

func (b *BadgerDatabase) FindMetaExact(key string, value interface{}) ([]*types.Class, error)

func (*BadgerDatabase) FindMetaExists

func (b *BadgerDatabase) FindMetaExists(key string) ([]*types.Class, error)

func (*BadgerDatabase) FindName

func (b *BadgerDatabase) FindName(name string) (*types.Class, error)

func (*BadgerDatabase) Get

func (b *BadgerDatabase) Get(id string) (*types.Class, error)

func (*BadgerDatabase) Insert

func (b *BadgerDatabase) Insert(c *types.Class) error

func (*BadgerDatabase) Iterator

func (b *BadgerDatabase) Iterator() Iterator

func (*BadgerDatabase) Open

func (b *BadgerDatabase) Open() error

func (*BadgerDatabase) RemoveMeta

func (b *BadgerDatabase) RemoveMeta(id, key string) error

func (*BadgerDatabase) RemoveMetaBulk

func (b *BadgerDatabase) RemoveMetaBulk(id string, keys []string) error

func (*BadgerDatabase) RemoveTag

func (b *BadgerDatabase) RemoveTag(id, tags string) error

func (*BadgerDatabase) RemoveTags

func (b *BadgerDatabase) RemoveTags(id string, tags []string) error

func (*BadgerDatabase) SetName

func (b *BadgerDatabase) SetName(id string, name string) error

type BadgerIterator

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

func (*BadgerIterator) Chan

func (b *BadgerIterator) Chan() chan *types.Class

func (*BadgerIterator) Error

func (b *BadgerIterator) Error() error

type Database

type Database interface {
	// Open the dbName connection
	Open() error

	// Close the dbName connection
	Close() error

	// Get a class from the database by its id
	Get(string) (*types.Class, error)

	// Batch get classes from a list of ids
	Batch([]string) ([]*types.Class, error)

	// Get all classes from the database
	All() ([]*types.Class, error)

	// Get a class iterator containing all classes in the database
	Iterator() Iterator

	// Insert a class into the database
	Insert(*types.Class) error

	// Delete a class from the database
	Delete(string) error

	// Set a class name
	SetName(string, string) error

	// Find classes by their name
	FindName(string) (*types.Class, error)

	// Add a tag to a class
	AddTag(string, string) error

	// Add tags to a class
	AddTags(string, []string) error

	// Remove a tag from a class
	RemoveTag(string, string) error

	// Remove tags from a class
	RemoveTags(string, []string) error

	// Find classes that contain at least one of the selected tags
	FindAnyTags([]string) ([]*types.Class, error)

	// Find classes that contain all of the selected tags
	FindAllTags([]string) ([]*types.Class, error)

	// Add metadata to the class
	AddMeta(string, string, interface{}) error

	// Add metadata to the class
	AddMetaBulk(string, map[string]interface{}) error

	// Remove metadata from the class
	RemoveMeta(string, string) error

	// Remove metadata from the class
	RemoveMetaBulk(string, []string) error

	// Find classes that have the specified meta key regardless of value
	FindMetaExists(string) ([]*types.Class, error)

	// Find classes that have the specified meta key with a specific value
	FindMetaExact(string, interface{}) ([]*types.Class, error)
}

type Iterator

type Iterator interface {
	Chan() chan *types.Class
	Error() error
}

A simple Iterator type which uses a channel to send values.

Error only needs to be called once the channel is closed to check for any errors.

type MongoDatabase

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

func NewMongo

func NewMongo(uri, db, collection string) *MongoDatabase

func (*MongoDatabase) AddMeta

func (m *MongoDatabase) AddMeta(id, key string, value interface{}) error

func (*MongoDatabase) AddMetaBulk

func (m *MongoDatabase) AddMetaBulk(id string, data map[string]interface{}) error

func (*MongoDatabase) AddTag

func (m *MongoDatabase) AddTag(id string, tag string) error

func (*MongoDatabase) AddTags

func (m *MongoDatabase) AddTags(id string, tags []string) error

func (*MongoDatabase) All

func (m *MongoDatabase) All() ([]*types.Class, error)

func (*MongoDatabase) Batch

func (m *MongoDatabase) Batch(ids []string) ([]*types.Class, error)

note: this badger function doesn't use iterators, because deserializing classes from bytes is slow.

func (*MongoDatabase) Close

func (m *MongoDatabase) Close() error

func (*MongoDatabase) Delete

func (m *MongoDatabase) Delete(id string) error

func (*MongoDatabase) FindAllTags

func (m *MongoDatabase) FindAllTags(tags []string) ([]*types.Class, error)

func (*MongoDatabase) FindAnyTags

func (m *MongoDatabase) FindAnyTags(tags []string) ([]*types.Class, error)

func (*MongoDatabase) FindMetaExact

func (m *MongoDatabase) FindMetaExact(key string, value interface{}) ([]*types.Class, error)

func (*MongoDatabase) FindMetaExists

func (m *MongoDatabase) FindMetaExists(key string) ([]*types.Class, error)

func (*MongoDatabase) FindName

func (m *MongoDatabase) FindName(name string) (*types.Class, error)

func (*MongoDatabase) Get

func (m *MongoDatabase) Get(id string) (*types.Class, error)

func (*MongoDatabase) Insert

func (m *MongoDatabase) Insert(class *types.Class) error

func (*MongoDatabase) Iterator

func (m *MongoDatabase) Iterator() Iterator

func (*MongoDatabase) Open

func (m *MongoDatabase) Open() error

func (*MongoDatabase) RemoveMeta

func (m *MongoDatabase) RemoveMeta(id, key string) error

func (*MongoDatabase) RemoveMetaBulk

func (m *MongoDatabase) RemoveMetaBulk(id string, keys []string) error

func (*MongoDatabase) RemoveTag

func (m *MongoDatabase) RemoveTag(id string, tag string) error

func (*MongoDatabase) RemoveTags

func (m *MongoDatabase) RemoveTags(id string, tags []string) error

func (*MongoDatabase) SetName

func (m *MongoDatabase) SetName(id string, name string) error

type MongoIterator

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

func (*MongoIterator) Chan

func (b *MongoIterator) Chan() chan *types.Class

func (*MongoIterator) Error

func (b *MongoIterator) Error() error

Jump to

Keyboard shortcuts

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