Documentation ¶
Overview ¶
Copyright (c) 2024 Eli Janssen Use of this source code is governed by an MIT-style license that can be found in the LICENSE file.
Copyright (c) 2024 Eli Janssen Use of this source code is governed by an MIT-style license that can be found in the LICENSE file.
Copyright (c) 2024 Eli Janssen Use of this source code is governed by an MIT-style license that can be found in the LICENSE file.
Copyright (c) 2024 Eli Janssen Use of this source code is governed by an MIT-style license that can be found in the LICENSE file.
Copyright (c) 2024 Eli Janssen Use of this source code is governed by an MIT-style license that can be found in the LICENSE file.
Copyright (c) 2024 Eli Janssen Use of this source code is governed by an MIT-style license that can be found in the LICENSE file.
Copyright (c) 2024 Eli Janssen Use of this source code is governed by an MIT-style license that can be found in the LICENSE file.
Copyright (c) 2024 Eli Janssen Use of this source code is governed by an MIT-style license that can be found in the LICENSE file.
Copyright (c) 2024 Eli Janssen Use of this source code is governed by an MIT-style license that can be found in the LICENSE file.
Copyright (c) 2024 Eli Janssen Use of this source code is governed by an MIT-style license that can be found in the LICENSE file.
Copyright (c) 2024 Eli Janssen Use of this source code is governed by an MIT-style license that can be found in the LICENSE file.
Copyright (c) 2024 Eli Janssen Use of this source code is governed by an MIT-style license that can be found in the LICENSE file.
Copyright (c) 2024 Eli Janssen Use of this source code is governed by an MIT-style license that can be found in the LICENSE file.
Copyright (c) 2024 Eli Janssen Use of this source code is governed by an MIT-style license that can be found in the LICENSE file.
Copyright (c) 2024 Eli Janssen Use of this source code is governed by an MIT-style license that can be found in the LICENSE file.
Copyright (c) 2024 Eli Janssen Use of this source code is governed by an MIT-style license that can be found in the LICENSE file.
Index ¶
- Constants
- Variables
- 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 Exec[T any](ctx context.Context, db PgxHandle, query string, args ...interface{}) error
- func ExecTx[T any](ctx context.Context, db PgxHandle, query string, args ...interface{}) error
- func Get[T any](ctx context.Context, db PgxHandle, query string, args ...interface{}) (T, error)
- func GetNotificationCountByUser(ctx context.Context, db PgxHandle, userID int) (int, error)
- func GetUserCredentialCountByUser(ctx context.Context, db PgxHandle, userID int) (int, error)
- func HashPass(ctx context.Context, rawPass []byte) ([]byte, error)
- func Query[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 QueryOneTx[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 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
- type ApiKeyRefID
- type BifurcatedRowCounts
- 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
- type Earmark
- 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
- type Event
- 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)
- type EventItem
- 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
- type EventItemRefID
- type EventRefID
- type EventUpdateModelValues
- type Favorite
- type Notification
- 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
- type PgxHandle
- type TimeZone
- type User
- 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)
- type UserCredential
- 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
- 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
- type UserPWReset
- 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
- type UserRefID
- type UserSettings
- type UserSettingsMatcher
- type UserUpdateModelValues
- type UserVerify
- 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
Constants ¶
const (
DefaultReminderThresholdHours = 24
)
const UserPWResetExpiry = 30 * time.Minute
const UserVerifyExpiry = 30 * time.Minute
Variables ¶
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]
Functions ¶
func DeleteEventItem ¶
func DeleteUserCredential ¶
func DeleteUserPWReset ¶
func DeleteUserPWReset(ctx context.Context, db PgxHandle, refID UserPWResetRefID, ) error
func DeleteUserVerify ¶
func DeleteUserVerify(ctx context.Context, db PgxHandle, refID UserVerifyRefID, ) error
func QueryOneTx ¶
func UpdateEarmark ¶
func UpdateEvent ¶
func UpdateEventItem ¶
func UpdateUser ¶
func UpdateUserSettings ¶
func ValidateReminderThresholdHours ¶
func ValidateReminderThresholdHours[T constraints.Unsigned](v T) (uint8, error)
Types ¶
type ApiKeyRefID ¶
type BifurcatedRowCounts ¶
func GetEarmarkCountByUser ¶
func GetEventCountsByUser ¶
func GetFavoriteCountByUser ¶
type CredentialRefID ¶
type Earmark ¶
type Earmark struct { Created time.Time LastModified time.Time `db:"last_modified"` Note string EventItemID int `db:"event_item_id"` UserID int `db:"user_id"` ID int RefID EarmarkRefID `db:"ref_id"` }
func CreateEarmark ¶
func GetEarmarkByEventItem ¶
func GetEarmarkByID ¶
func GetEarmarkByRefID ¶
func GetEarmarksByEvent ¶
type EarmarkRefID ¶
type Event ¶
type Event struct { Created time.Time LastModified time.Time `db:"last_modified"` StartTime time.Time `db:"start_time"` StartTimeTz *TimeZone `db:"start_time_tz"` Name string Description string ItemSortOrder []int `db:"item_sort_order"` Archived bool UserID int `db:"user_id"` ID int RefID EventRefID `db:"ref_id"` }
func CreateEvent ¶
func GetEventByEventItemID ¶
func GetEventByID ¶
func GetEventByRefID ¶
func GetEventsByIDs ¶
func GetEventsByUserFiltered ¶
type EventItem ¶
type EventItem struct { Created time.Time LastModified time.Time `db:"last_modified"` Description string EventID int `db:"event_id"` ID int RefID EventItemRefID `db:"ref_id"` }
func CreateEventItem ¶
func GetEventItemByID ¶
func GetEventItemByRefID ¶
func GetEventItemsByEvent ¶
func GetEventItemsByIDs ¶
type EventItemCount ¶
type EventItemRefID ¶
type EventRefID ¶
type EventUpdateModelValues ¶
type Favorite ¶
type Favorite struct { Created time.Time EventID int `db:"event_id"` UserID int `db:"user_id"` ID int }
func CreateFavorite ¶
func GetFavoriteByID ¶
type Notification ¶
type Notification struct { Created time.Time LastModified time.Time `db:"last_modified"` Message string UserID int `db:"user_id"` ID int RefID NotificationRefID `db:"ref_id"` Read bool }
func CreateNotification ¶
func CreateNotification(ctx context.Context, db PgxHandle, refID NotificationRefID, userID int, message string, ) (*Notification, error)
func GetNotificationByID ¶
func GetNotificationByRefID ¶
func GetNotificationByRefID(ctx context.Context, db PgxHandle, refID NotificationRefID, ) (*Notification, error)
func GetNotificationsByUser ¶
func NewNotification ¶
func UpdateNotification ¶
type NotificationRefID ¶
type TimeZone ¶
type User ¶
type User struct { Created time.Time LastModified time.Time `db:"last_modified"` Email string Name string PWHash []byte ID int RefID UserRefID `db:"ref_id"` Settings UserSettings Verified bool PWAuth bool ApiAccess bool `db:"api_access"` WebAuthn bool }
func CreateUser ¶
func GetUserByApiKey ¶
func GetUserByEmail ¶
func GetUserByRefID ¶
func GetUsersByIDs ¶
type UserCredential ¶
type UserCredential struct { Created time.Time KeyName string `db:"key_name"` Credential []byte UserID int `db:"user_id"` ID int RefID CredentialRefID `db:"ref_id"` }
func CreateUserCredential ¶
func CreateUserCredential(ctx context.Context, db PgxHandle, refID CredentialRefID, userID int, keyName string, credential []byte, ) (*UserCredential, error)
func GetUserCredentialByRefID ¶
func GetUserCredentialByRefID(ctx context.Context, db PgxHandle, refID CredentialRefID, ) (*UserCredential, error)
func NewUserCredential ¶
type UserEventNotification ¶
type UserEventNotification struct { Created time.Time UserID int `db:"user_id"` EventID int `db:"event_id"` }
type UserEventNotificationNeeded ¶
type UserEventNotificationNeeded struct { When time.Time EventItemIDs []int `db:"items"` UserID int `db:"user_id"` EventID int `db:"event_id"` Owner bool }
func GetUserEventNotificationNeeded ¶
func GetUserEventNotificationNeeded( ctx context.Context, db PgxHandle, ) ([]*UserEventNotificationNeeded, error)
type UserPWReset ¶
type UserPWReset struct { Created time.Time UserID int `db:"user_id"` RefID UserPWResetRefID `db:"ref_id"` }
func CreateUserPWReset ¶
func CreateUserPWReset(ctx context.Context, db PgxHandle, refID UserPWResetRefID, userID int, ) (*UserPWReset, error)
func GetUserPWResetByRefID ¶
func GetUserPWResetByRefID(ctx context.Context, db PgxHandle, refID UserPWResetRefID, ) (*UserPWReset, error)
func NewUserPWReset ¶
type UserPWResetRefID ¶
type UserSettings ¶
type UserSettings struct { ReminderThresholdHours uint8 `json:"reminder_threshold"` // weird negative name here, so zero value defaults // to enabling reminders EnableReminders bool `json:"enable_reminders"` }
func NewUserPropertyMap ¶
func NewUserPropertyMap() *UserSettings
func (*UserSettings) Scan ¶
func (p *UserSettings) Scan(src interface{}) error
type UserSettingsMatcher ¶
type UserSettingsMatcher struct {
// contains filtered or unexported fields
}
func NewUserSettingsMatcher ¶
func NewUserSettingsMatcher(expected UserSettings) UserSettingsMatcher
func (UserSettingsMatcher) Match ¶
func (m UserSettingsMatcher) Match(v interface{}) bool
type UserUpdateModelValues ¶
type UserVerify ¶
type UserVerify struct { Created time.Time UserID int `db:"user_id"` RefID UserVerifyRefID `db:"ref_id"` }
func CreateUserVerify ¶
func CreateUserVerify(ctx context.Context, db PgxHandle, refID UserVerifyRefID, userID int, ) (*UserVerify, error)
func GetUserVerifyByRefID ¶
func GetUserVerifyByRefID(ctx context.Context, db PgxHandle, refID UserVerifyRefID, ) (*UserVerify, error)