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 ¶
- type DB
- func (db *DB) Close() error
- func (db *DB) DelDiaryEntries(id int, entries ...core.DiaryEntry) error
- func (db *DB) DelRecipeInstructions(id int) error
- func (db *DB) DelToken(hash string) error
- func (db *DB) DelUser(id int) error
- func (db *DB) DiaryDays(id, year, month, day int) ([]core.DiaryDay, error)
- func (db *DB) DiaryEntries(id int, date time.Time) ([]core.DiaryEntry, error)
- func (db *DB) Execute(c app.Command) error
- func (db *DB) Fetch(q app.Query) error
- func (db *DB) Food(id int) (core.Food, error)
- func (db *DB) FoodExists(id int) (bool, error)
- func (db *DB) Foods(filter core.Filter) ([]core.Food, error)
- func (db *DB) NewDiaryEntries(id int, entries ...core.DiaryEntry) error
- func (db *DB) NewFood() (int, error)
- func (db *DB) NewRecipe(name string) (int, error)
- func (db *DB) NewToken(id int, hash string, data interface{}) error
- func (db *DB) NewUser(email, hash, token string) (int, error)
- func (db *DB) Recipe(id int) (core.Recipe, error)
- func (db *DB) RecipeAccess(user, rec int) (int, error)
- func (db *DB) RecipeInstructions(id int) (string, error)
- func (db *DB) Recipes(uid int, f core.Filter) ([]core.Recipe, error)
- func (db *DB) SetDiaryEntries(id int, entries ...core.DiaryEntry) error
- func (db *DB) SetFood(food core.Food) error
- func (db *DB) SetRecipe(rec core.Recipe) error
- func (db *DB) SetRecipeAccess(user, rec, perms int) error
- func (db *DB) SetRecipeInstructions(id int, text string) error
- func (db *DB) SetShoppingListDone(id int, done map[int]bool) error
- func (db *DB) SetUser(user app.User) error
- func (db *DB) SetUserPrefs(id int, prefs app.StoredPrefs) error
- func (db *DB) ShoppingList(id int, date ...time.Time) ([]core.ShopItem, error)
- func (db *DB) Token(hash string) (app.Token, error)
- func (db *DB) UserByEmail(email string) (app.User, error)
- func (db *DB) UserByID(id int) (app.User, error)
- func (db *DB) UserByName(name string) (app.User, error)
- func (db *DB) UserNames(prefix string) ([]string, error)
- func (db *DB) UserPrefs(id int) (app.StoredPrefs, error)
- func (db *DB) WithBackup(log app.Logger) *DB
- func (db *DB) WithDefaults(fs fs.FS) *DB
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 (*DB) DelDiaryEntries ¶
func (db *DB) DelDiaryEntries(id int, entries ...core.DiaryEntry) error
func (*DB) DelRecipeInstructions ¶
func (*DB) DiaryEntries ¶
func (*DB) NewDiaryEntries ¶
func (db *DB) NewDiaryEntries(id int, entries ...core.DiaryEntry) error
func (*DB) SetDiaryEntries ¶
func (db *DB) SetDiaryEntries(id int, entries ...core.DiaryEntry) error
func (*DB) SetRecipeAccess ¶
func (*DB) SetUserPrefs ¶
func (db *DB) SetUserPrefs(id int, prefs app.StoredPrefs) error
func (*DB) ShoppingList ¶
Click to show internal directories.
Click to hide internal directories.