Documentation
¶
Overview ¶
Package store (pieces ⑬ and ⑭) owns the SQLite database: opening it with safe pragmas, running migrations after an automatic backup, and mapping rows to domain types. Queries are generated by sqlc into store/db.
Index ¶
- Constants
- func CategoryFromRow(r db.Category) domain.Category
- func ChargeFromRow(r db.Charge) domain.Charge
- func ChargeUpdate(c domain.Charge, now time.Time) db.UpdateChargeParams
- func DatePtr(d engine.Date) *string
- func FormatTime(t time.Time) string
- func HouseholdFromRow(r db.Household) domain.Household
- func MemberFromRow(r db.Member) domain.Member
- func NotFound(err error, format string, args ...any) error
- func ParseTime(s string) time.Time
- func PaymentMethodFromRow(r db.PaymentMethod) domain.PaymentMethod
- func Ptr(s string) *string
- func Str(p *string) string
- func SubscriptionFromRow(r db.Subscription) (domain.Subscription, error)
- func SubscriptionJSON(s domain.Subscription) (schedule, reminders, details string, err error)
- type Store
Constants ¶
const TimeFormat = time.RFC3339Nano
TimeFormat is how instants are stored (UTC, sortable).
Variables ¶
This section is empty.
Functions ¶
func ChargeUpdate ¶
ChargeUpdate builds the update parameters for c (optimistic locking on c.Version).
func NotFound ¶
NotFound converts sql.ErrNoRows into domain.ErrNotFound, with a sentence such as "subscription %s: not found" (see domain.Missing).
func PaymentMethodFromRow ¶
func PaymentMethodFromRow(r db.PaymentMethod) domain.PaymentMethod
func SubscriptionFromRow ¶
func SubscriptionFromRow(r db.Subscription) (domain.Subscription, error)
func SubscriptionJSON ¶
func SubscriptionJSON(s domain.Subscription) (schedule, reminders, details string, err error)
SubscriptionJSON returns the JSON columns of a subscription.
Types ¶
type Store ¶
Store is the database handle.
func Open ¶
Open opens (or creates) the database in dataDir, backs it up if migrations are pending, and migrates it to the latest version.
func OpenMemory ¶
OpenMemory opens a private in-memory database, for tests.