scribble

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2024 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package scribble is a tiny JSON database

Index

Constants

View Source
const Version = "1.0.4"

Version is the current version of the project

Variables

View Source
var (
	ErrMissingResource   = errors.New("missing resource - unable to save record")
	ErrMissingCollection = errors.New("missing collection - no place to save record")
)

Functions

This section is empty.

Types

type Driver

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

Driver is what is used to interact with the scribble database. It runs transactions, and provides log output

func New

func New(dir string, options *Options) (*Driver, error)

New creates a new scribble database at the desired directory location, and returns a *Driver to then use for interacting with the database

func (*Driver) Delete

func (d *Driver) Delete(collection, resource string) error

Delete locks the database then attempts to remove the collection/resource specified by path

func (*Driver) Read

func (d *Driver) Read(collection, resource string, v interface{}) error

Read a record from the database

func (*Driver) ReadAll

func (d *Driver) ReadAll(collection string) ([][]byte, error)

ReadAll records from a collection; this is returned as a slice of strings because there is no way of knowing what type the record is.

func (*Driver) Write

func (d *Driver) Write(collection, resource string, v interface{}) error

Write locks the database and attempts to write the record to the database under the [collection] specified with the [resource] name given

type Logger

type Logger interface {
	Fatal(string, ...interface{})
	Error(string, ...interface{})
	Warn(string, ...interface{})
	Info(string, ...interface{})
	Debug(string, ...interface{})
	Trace(string, ...interface{})
}

Logger is a generic logger interface

type Options

type Options struct {
	Logger // the logger scribble will use (configurable)
}

Options uses for specification of working golang-scribble

Jump to

Keyboard shortcuts

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