json

package
v0.0.0-...-c891680 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package json implements a data store using a single JSON file and the memory package.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrFileIsDirectory = errors.New("file is a directory")
)

Functions

This section is empty.

Types

type Database

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

Database is the JSON file implementation of the database store.

func NewDatabase

func NewDatabase(memory *memory.Database, filepath string) *Database

NewDatabase creates a JSON Database object with the memory database and filepath given. Its `Start` method will either initialize the JSON database file or load existing data from an existing JSON file into the memory database.

func (*Database) CreateUser

func (db *Database) CreateUser(ctx context.Context, user models.User) (err error)

func (*Database) GetUserByID

func (db *Database) GetUserByID(ctx context.Context, id uint64) (user models.User, err error)

func (*Database) Start

func (db *Database) Start(ctx context.Context) (runError <-chan error, err error)

func (*Database) Stop

func (db *Database) Stop() (err error)

func (*Database) String

func (db *Database) String() string

Jump to

Keyboard shortcuts

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