jsondb

package
v0.0.0-...-8eefd04 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2024 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 JSONDatabase

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

func New

func New(dir string, perm os.FileMode) *JSONDatabase

Create a new JSONDatabase in `dir`. Each document that is saved to it will have a file mode of `perm`.

func (*JSONDatabase) List

func (db *JSONDatabase) List() ([]string, error)

Returns a list of all documents' names.

func (*JSONDatabase) Read

func (db *JSONDatabase) Read(name string, document interface{}) (bool, error)

Reads the value at `name`. `document` must be a type that is deserializable from the JSON document `name`, or nil to not deserialize at all. Returns false if a document with `name` does not exist.

func (*JSONDatabase) Write

func (db *JSONDatabase) Write(name string, document interface{}) error

Writes `document` to `name`, overwriting a previous document if it exists. `document` must be serializable to JSON.

Jump to

Keyboard shortcuts

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