Versions in this module Expand all Collapse all v1 v1.2.0 Dec 22, 2024 v1.1.0 Sep 22, 2024 v1.0.1 Jun 24, 2024 v1.0.0 May 18, 2024 Changes in this version + const DefaultReminderThresholdHours + const UserPWResetExpiry + const UserVerifyExpiry + var NewApiKeyRefID = reftag.NewRandom[ApiKeyRefID] + var NewCredentialRefID = reftag.New[CredentialRefID] + var NewEarmarkRefID = reftag.New[EarmarkRefID] + var NewEventItemRefID = reftag.New[EventItemRefID] + var NewEventRefID = reftag.New[EventRefID] + var NewNotificationRefID = reftag.New[NotificationRefID] + var NewUserPWResetRefID = reftag.New[UserPWResetRefID] + var NewUserRefID = reftag.New[UserRefID] + var NewUserVerifyRefID = reftag.New[UserVerifyRefID] + func ArchiveOldEvents(ctx context.Context, db PgxHandle) error + func CheckPass(ctx context.Context, pwHash []byte, rawPass []byte) (bool, error) + func DeleteEarmark(ctx context.Context, db PgxHandle, earmarkID int) error + func DeleteEvent(ctx context.Context, db PgxHandle, eventID int) error + func DeleteEventItem(ctx context.Context, db PgxHandle, eventItemID int) error + func DeleteFavorite(ctx context.Context, db PgxHandle, favID int) error + func DeleteNotification(ctx context.Context, db PgxHandle, ID int) error + func DeleteNotificationsByUser(ctx context.Context, db PgxHandle, userID int) error + func DeleteUser(ctx context.Context, db PgxHandle, userID int) error + func DeleteUserCredential(ctx context.Context, db PgxHandle, ID int) error + func DeleteUserEventNotification(ctx context.Context, db PgxHandle, userID int, eventID int) error + func DeleteUserPWReset(ctx context.Context, db PgxHandle, refID UserPWResetRefID) error + func DeleteUserVerify(ctx context.Context, db PgxHandle, refID UserVerifyRefID) error + func ExecTx[T any](ctx context.Context, db PgxHandle, query string, args ...interface{}) error + func Exec[T any](ctx context.Context, db PgxHandle, query string, args ...interface{}) error + func GetNotificationCountByUser(ctx context.Context, db PgxHandle, userID int) (int, error) + func GetUserCredentialCountByUser(ctx context.Context, db PgxHandle, userID int) (int, error) + func Get[T any](ctx context.Context, db PgxHandle, query string, args ...interface{}) (T, error) + func HashPass(ctx context.Context, rawPass []byte) ([]byte, error) + func QueryOneTx[T any](ctx context.Context, db PgxHandle, query string, args ...interface{}) (*T, error) + func QueryOne[T any](ctx context.Context, db PgxHandle, query string, args ...interface{}) (*T, error) + func QueryTx[T any](ctx context.Context, db PgxHandle, query string, args ...interface{}) ([]*T, error) + func Query[T any](ctx context.Context, db PgxHandle, query string, args ...interface{}) ([]*T, error) + func SetupDBPool(dbDSN string, tracing bool) (*pgxpool.Pool, error) + func UpdateEarmark(ctx context.Context, db PgxHandle, earmarkID int, note string) error + func UpdateEvent(ctx context.Context, db PgxHandle, eventID int, vals *EventUpdateModelValues) error + func UpdateEventItem(ctx context.Context, db PgxHandle, eventItemID int, description string) error + func UpdateUser(ctx context.Context, db PgxHandle, userID int, vals *UserUpdateModelValues) error + func UpdateUserSettings(ctx context.Context, db PgxHandle, userID int, pm *UserSettings) error + func ValidateReminderThresholdHours[T constraints.Unsigned](v T) (uint8, error) + type ApiKey struct + Created time.Time + Token string + UserID int + func CreateApiKey(ctx context.Context, db PgxHandle, userID int, token string) (*ApiKey, error) + func GetApiKeyByUser(ctx context.Context, db PgxHandle, userID int) (*ApiKey, error) + func NewApiKey(ctx context.Context, db PgxHandle, userID int) (*ApiKey, error) + type ApiKeyRefID struct + type BifurcatedRowCounts struct + Archived int + Current int + func GetEarmarkCountByUser(ctx context.Context, db PgxHandle, userID int) (*BifurcatedRowCounts, error) + func GetEventCountsByUser(ctx context.Context, db PgxHandle, userID int) (*BifurcatedRowCounts, error) + func GetFavoriteCountByUser(ctx context.Context, db PgxHandle, userID int) (*BifurcatedRowCounts, error) + type CredentialRefID struct + type Earmark struct + Created time.Time + EventItemID int + ID int + LastModified time.Time + Note string + RefID EarmarkRefID + UserID int + func CreateEarmark(ctx context.Context, db PgxHandle, refID EarmarkRefID, eventItemID int, ...) (*Earmark, error) + func GetEarmarkByEventItem(ctx context.Context, db PgxHandle, eventItemID int) (*Earmark, error) + func GetEarmarkByID(ctx context.Context, db PgxHandle, earmarkID int) (*Earmark, error) + func GetEarmarkByRefID(ctx context.Context, db PgxHandle, refID EarmarkRefID) (*Earmark, error) + func GetEarmarksByEvent(ctx context.Context, db PgxHandle, eventID int) ([]*Earmark, error) + func GetEarmarksByEventItemIDs(ctx context.Context, db PgxHandle, eventItemIDs []int) ([]*Earmark, error) + func GetEarmarksByUserFiltered(ctx context.Context, db PgxHandle, userID int, archived bool) ([]*Earmark, error) + func GetEarmarksByUserPaginated(ctx context.Context, db PgxHandle, userID int, limit, offset int) ([]*Earmark, error) + func GetEarmarksByUserPaginatedFiltered(ctx context.Context, db PgxHandle, userID int, limit, offset int, ...) ([]*Earmark, error) + func NewEarmark(ctx context.Context, db PgxHandle, eventItemID, userID int, note string) (*Earmark, error) + type EarmarkRefID struct + type Event struct + Archived bool + Created time.Time + Description string + ID int + ItemSortOrder []int + LastModified time.Time + Name string + RefID EventRefID + StartTime time.Time + StartTimeTz *TimeZone + UserID int + func CreateEvent(ctx context.Context, db PgxHandle, refID EventRefID, userID int, ...) (*Event, error) + func GetEventByEventItemID(ctx context.Context, db PgxHandle, eventItemID int) (*Event, error) + func GetEventByID(ctx context.Context, db PgxHandle, eventID int) (*Event, error) + func GetEventByRefID(ctx context.Context, db PgxHandle, refID EventRefID) (*Event, error) + func GetEventsByIDs(ctx context.Context, db PgxHandle, eventIDs []int) ([]*Event, error) + func GetEventsByUserFiltered(ctx context.Context, db PgxHandle, userID int, archived bool) ([]*Event, error) + func GetEventsByUserPaginated(ctx context.Context, db PgxHandle, userID int, limit, offset int) ([]*Event, error) + func GetEventsByUserPaginatedFiltered(ctx context.Context, db PgxHandle, userID int, limit, offset int, ...) ([]*Event, error) + func GetEventsComingSoonByUserPaginated(ctx context.Context, db PgxHandle, userID int, limit, offset int) ([]*Event, error) + func GetFavoriteEventsByUserFiltered(ctx context.Context, db PgxHandle, userID int, archived bool) ([]*Event, error) + func GetFavoriteEventsByUserPaginatedFiltered(ctx context.Context, db PgxHandle, userID int, limit, offset int, ...) ([]*Event, error) + func NewEvent(ctx context.Context, db PgxHandle, userID int, name, description string, ...) (*Event, error) + func (ev *Event) When() time.Time + type EventItem struct + Created time.Time + Description string + EventID int + ID int + LastModified time.Time + RefID EventItemRefID + func CreateEventItem(ctx context.Context, db PgxHandle, refID EventItemRefID, eventID int, ...) (*EventItem, error) + func GetEventItemByID(ctx context.Context, db PgxHandle, eventItemID int) (*EventItem, error) + func GetEventItemByRefID(ctx context.Context, db PgxHandle, refID EventItemRefID) (*EventItem, error) + func GetEventItemsByEvent(ctx context.Context, db PgxHandle, eventID int) ([]*EventItem, error) + func GetEventItemsByIDs(ctx context.Context, db PgxHandle, eventItemIDs []int) ([]*EventItem, error) + func NewEventItem(ctx context.Context, db PgxHandle, eventID int, description string) (*EventItem, error) + type EventItemCount struct + Count int + EventID int + func GetEventItemsCountByEventIDs(ctx context.Context, db PgxHandle, eventIDs []int) ([]*EventItemCount, error) + type EventItemRefID struct + type EventRefID struct + type EventUpdateModelValues struct + Description mo.Option[string] + ItemSortOrder mo.Option[[]int] + Name mo.Option[string] + StartTime mo.Option[time.Time] + Tz mo.Option[*TimeZone] + type Favorite struct + Created time.Time + EventID int + ID int + UserID int + func CreateFavorite(ctx context.Context, db PgxHandle, userID int, eventID int) (*Favorite, error) + func GetFavoriteByID(ctx context.Context, db PgxHandle, favID int) (*Favorite, error) + func GetFavoriteByUserEvent(ctx context.Context, db PgxHandle, userID int, eventID int) (*Favorite, error) + type Notification struct + Created time.Time + ID int + LastModified time.Time + Message string + Read bool + RefID NotificationRefID + UserID int + func CreateNotification(ctx context.Context, db PgxHandle, refID NotificationRefID, userID int, ...) (*Notification, error) + func GetNotificationByID(ctx context.Context, db PgxHandle, ID int) (*Notification, error) + func GetNotificationByRefID(ctx context.Context, db PgxHandle, refID NotificationRefID) (*Notification, error) + func GetNotificationsByUser(ctx context.Context, db PgxHandle, userID int) ([]*Notification, error) + func GetNotificationsByUserPaginated(ctx context.Context, db PgxHandle, userID int, limit, offset int) ([]*Notification, error) + func NewNotification(ctx context.Context, db PgxHandle, userID int, message string) (*Notification, error) + func UpdateNotification(ctx context.Context, db PgxHandle, ID int, read bool) (*Notification, error) + type NotificationRefID struct + type PgxHandle interface + Begin func(ctx context.Context) (pgx.Tx, error) + Exec func(ctx context.Context, sql string, arguments ...any) (pgconn.CommandTag, error) + Query func(ctx context.Context, query string, args ...interface{}) (pgx.Rows, error) + QueryRow func(context.Context, string, ...interface{}) pgx.Row + type TimeZone struct + func (tz *TimeZone) Scan(src interface{}) error + func (tz TimeZone) Equal(other TimeZone) bool + func (tz TimeZone) Value() (driver.Value, error) + type User struct + ApiAccess bool + Created time.Time + Email string + ID int + LastModified time.Time + Name string + PWAuth bool + PWHash []byte + RefID UserRefID + Settings UserSettings + Verified bool + WebAuthn bool + func CreateUser(ctx context.Context, db PgxHandle, refID UserRefID, email, name string, ...) (*User, error) + func GetUserByApiKey(ctx context.Context, db PgxHandle, token string) (*User, error) + func GetUserByEmail(ctx context.Context, db PgxHandle, email string) (*User, error) + func GetUserByID(ctx context.Context, db PgxHandle, userID int) (*User, error) + func GetUserByRefID(ctx context.Context, db PgxHandle, refID UserRefID) (*User, error) + func GetUsersByIDs(ctx context.Context, db PgxHandle, userIDs []int) ([]*User, error) + func NewUser(ctx context.Context, db PgxHandle, email, name string, rawPass []byte) (*User, error) + func (u User) LogValue() slog.Value + type UserCredential struct + Created time.Time + Credential []byte + ID int + KeyName string + RefID CredentialRefID + UserID int + func CreateUserCredential(ctx context.Context, db PgxHandle, refID CredentialRefID, userID int, ...) (*UserCredential, error) + func GetUserCredentialByRefID(ctx context.Context, db PgxHandle, refID CredentialRefID) (*UserCredential, error) + func GetUserCredentialsByUser(ctx context.Context, db PgxHandle, userID int) ([]*UserCredential, error) + func NewUserCredential(ctx context.Context, db PgxHandle, userID int, keyName string, ...) (*UserCredential, error) + type UserEventNotification struct + Created time.Time + EventID int + UserID int + func CreateUserEventNotification(ctx context.Context, db PgxHandle, userID int, eventID int) (*UserEventNotification, error) + func GetUserEventNotification(ctx context.Context, db PgxHandle, userID int, eventID int) (*UserEventNotification, error) + func NewUserEventNotification(ctx context.Context, db PgxHandle, userID int, eventID int) (*UserEventNotification, error) + type UserEventNotificationNeeded struct + EventID int + EventItemIDs []int + Owner bool + UserID int + When time.Time + func GetUserEventNotificationNeeded(ctx context.Context, db PgxHandle) ([]*UserEventNotificationNeeded, error) + type UserPWReset struct + Created time.Time + RefID UserPWResetRefID + UserID int + func CreateUserPWReset(ctx context.Context, db PgxHandle, refID UserPWResetRefID, userID int) (*UserPWReset, error) + func GetUserPWResetByRefID(ctx context.Context, db PgxHandle, refID UserPWResetRefID) (*UserPWReset, error) + func NewUserPWReset(ctx context.Context, db PgxHandle, userID int) (*UserPWReset, error) + type UserPWResetRefID struct + type UserRefID struct + type UserSettings struct + EnableReminders bool + ReminderThresholdHours uint8 + func NewUserPropertyMap() *UserSettings + func (p *UserSettings) Scan(src interface{}) error + func (p UserSettings) Value() (driver.Value, error) + type UserSettingsMatcher struct + func NewUserSettingsMatcher(expected UserSettings) UserSettingsMatcher + func (m UserSettingsMatcher) Match(v interface{}) bool + type UserUpdateModelValues struct + ApiAccess mo.Option[bool] + Email mo.Option[string] + Name mo.Option[string] + PWAuth mo.Option[bool] + PWHash mo.Option[[]byte] + Verified mo.Option[bool] + WebAuthn mo.Option[bool] + type UserVerify struct + Created time.Time + RefID UserVerifyRefID + UserID int + func CreateUserVerify(ctx context.Context, db PgxHandle, refID UserVerifyRefID, userID int) (*UserVerify, error) + func GetUserVerifyByRefID(ctx context.Context, db PgxHandle, refID UserVerifyRefID) (*UserVerify, error) + func NewUserVerify(ctx context.Context, db PgxHandle, userID int) (*UserVerify, error) + type UserVerifyRefID struct