mem

package
v0.0.0-...-5963d61 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

package mem provides an implementation of the app.DB interface that lives entirely in the application's runtime memory. It can be saved to and loaded from JSON files for persistence.

It performs well, but it's absolutely not intended to be used on a large user base. Deployments with more than 50 to 100 users should be set up with a proper database management system.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

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

func NewDB

func NewDB() *DB

func (*DB) Close

func (db *DB) Close() error

func (*DB) DelDiaryEntries

func (db *DB) DelDiaryEntries(id int, entries ...core.DiaryEntry) error

func (*DB) DelRecipeInstructions

func (db *DB) DelRecipeInstructions(id int) error

func (*DB) DelToken

func (db *DB) DelToken(hash string) error

func (*DB) DelUser

func (db *DB) DelUser(id int) error

func (*DB) DiaryDays

func (db *DB) DiaryDays(id, year, month, day int) ([]core.DiaryDay, error)

func (*DB) DiaryEntries

func (db *DB) DiaryEntries(id int, date time.Time) ([]core.DiaryEntry, error)

func (*DB) Execute

func (db *DB) Execute(c app.Command) error

func (*DB) Fetch

func (db *DB) Fetch(q app.Query) error

func (*DB) Food

func (db *DB) Food(id int) (core.Food, error)

func (*DB) FoodExists

func (db *DB) FoodExists(id int) (bool, error)

func (*DB) Foods

func (db *DB) Foods(filter core.Filter) ([]core.Food, error)

func (*DB) NewDiaryEntries

func (db *DB) NewDiaryEntries(id int, entries ...core.DiaryEntry) error

func (*DB) NewFood

func (db *DB) NewFood() (int, error)

func (*DB) NewRecipe

func (db *DB) NewRecipe(name string) (int, error)

func (*DB) NewToken

func (db *DB) NewToken(id int, hash string, data interface{}) error

func (*DB) NewUser

func (db *DB) NewUser(email, hash, token string) (int, error)

func (*DB) Recipe

func (db *DB) Recipe(id int) (core.Recipe, error)

func (*DB) RecipeAccess

func (db *DB) RecipeAccess(user, rec int) (int, error)

func (*DB) RecipeInstructions

func (db *DB) RecipeInstructions(id int) (string, error)

func (*DB) Recipes

func (db *DB) Recipes(uid int, f core.Filter) ([]core.Recipe, error)

func (*DB) SetDiaryEntries

func (db *DB) SetDiaryEntries(id int, entries ...core.DiaryEntry) error

func (*DB) SetFood

func (db *DB) SetFood(food core.Food) error

func (*DB) SetRecipe

func (db *DB) SetRecipe(rec core.Recipe) error

func (*DB) SetRecipeAccess

func (db *DB) SetRecipeAccess(user, rec, perms int) error

func (*DB) SetRecipeInstructions

func (db *DB) SetRecipeInstructions(id int, text string) error

func (*DB) SetShoppingListDone

func (db *DB) SetShoppingListDone(id int, done map[int]bool) error

func (*DB) SetUser

func (db *DB) SetUser(user app.User) error

func (*DB) SetUserPrefs

func (db *DB) SetUserPrefs(id int, prefs app.StoredPrefs) error

func (*DB) ShoppingList

func (db *DB) ShoppingList(id int, date ...time.Time) ([]core.ShopItem, error)

func (*DB) Token

func (db *DB) Token(hash string) (app.Token, error)

func (*DB) UserByEmail

func (db *DB) UserByEmail(email string) (app.User, error)

func (*DB) UserByID

func (db *DB) UserByID(id int) (app.User, error)

func (*DB) UserByName

func (db *DB) UserByName(name string) (app.User, error)

func (*DB) UserNames

func (db *DB) UserNames(prefix string) ([]string, error)

func (*DB) UserPrefs

func (db *DB) UserPrefs(id int) (app.StoredPrefs, error)

func (*DB) WithBackup

func (db *DB) WithBackup(log app.Logger) *DB

func (*DB) WithDefaults

func (db *DB) WithDefaults(fs fs.FS) *DB

Jump to

Keyboard shortcuts

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