Documentation ¶
Overview ¶
Package data provides the database abstraction layer and helpers for the Phi Mu Alpha Sinfonia - Delta Iota chapter website.
Index ¶
- Variables
- type DB
- func (db *DB) Begin() (*Tx, error)
- func (db *DB) Close() error
- func (db *DB) DeleteNotification(n *models.Notification) error
- func (db *DB) DeleteNotificationsByUserID(userID uint64) error
- func (db *DB) DeleteSession(s *models.Session) error
- func (db *DB) DeleteSessionsByUserID(userID uint64) error
- func (db *DB) DeleteUser(u *models.User) error
- func (db *DB) InsertNotification(n *models.Notification) error
- func (db *DB) InsertSession(s *models.Session) error
- func (db *DB) InsertUser(u *models.User) error
- func (db *DB) IsConstraintFailure(err error) bool
- func (db *DB) IsReadonly(err error) bool
- func (db *DB) Open(driver string, dsn string) error
- func (db *DB) SelectAllUsers() ([]*models.User, error)
- func (db *DB) SelectNotificationsByUserID(userID uint64) ([]*models.Notification, error)
- func (db *DB) SelectSessionByKey(key string) (*models.Session, error)
- func (db *DB) SelectUserByID(id uint64) (*models.User, error)
- func (db *DB) SelectUserByUsername(username string) (*models.User, error)
- func (db *DB) UpdateNotification(n *models.Notification) error
- func (db *DB) UpdateSession(s *models.Session) error
- func (db *DB) UpdateUser(u *models.User) error
- func (db *DB) WithTx(fn func(tx *Tx) error) error
- type Rows
- type Tx
- func (tx *Tx) DeleteNotification(n *models.Notification) error
- func (tx *Tx) DeleteNotificationsByUserID(userID uint64) error
- func (tx *Tx) DeleteSession(s *models.Session) error
- func (tx *Tx) DeleteSessionsByUserID(userID uint64) error
- func (tx *Tx) DeleteUser(u *models.User) error
- func (tx *Tx) InsertNotification(n *models.Notification) error
- func (tx *Tx) InsertSession(s *models.Session) error
- func (tx *Tx) InsertUser(u *models.User) error
- func (tx *Tx) UpdateNotification(n *models.Notification) error
- func (tx *Tx) UpdateSession(s *models.Session) error
- func (tx *Tx) UpdateUser(u *models.User) error
Constants ¶
This section is empty.
Variables ¶
var ( // ErrMultipleResults is returned when a query should return only zero or a single // result, but returns two or more results. ErrMultipleResults = errors.New("db: multiple results returned") )
Functions ¶
This section is empty.
Types ¶
type DB ¶
DB provides the database abstraction layer for the application.
func (*DB) DeleteNotification ¶
func (db *DB) DeleteNotification(n *models.Notification) error
DeleteNotification starts a transaction, deletes the input Notification by its ID, and attempts to commit the transaction.
func (*DB) DeleteNotificationsByUserID ¶
DeleteNotificationsByUserID starts a transaction, deletes all Notifications with the matching user ID, and attempts to commit the transaction.
func (*DB) DeleteSession ¶
DeleteSession starts a transaction, deletes the input Session by its ID, and attempts to commit the transaction.
func (*DB) DeleteSessionsByUserID ¶
DeleteSessionsByUserID starts a transaction, deletes all Sessions with the matching user ID, and attempts to commit the transaction.
func (*DB) DeleteUser ¶
DeleteUser starts a transaction, deletes the input User by its ID, and attempts to commit the transaction.
func (*DB) InsertNotification ¶
func (db *DB) InsertNotification(n *models.Notification) error
InsertNotification starts a transaction, inserts a new Notification, and attempts to commit the transaction.
func (*DB) InsertSession ¶
InsertSession starts a transaction, inserts a new Session, and attempts to commit the transaction.
func (*DB) InsertUser ¶
InsertUser starts a transaction, inserts a new User, and attempts to commit the transaction.
func (*DB) IsConstraintFailure ¶
IsConstraintFailure returns whether or not an input error is due to a failed database constraint, such as an insert of an item which is not unique.
func (*DB) IsReadonly ¶
IsReadonly returns whether or not an input error is due to a readonly database.
func (*DB) SelectAllUsers ¶
SelectAllUsers returns a slice of all Users from the database.
func (*DB) SelectNotificationsByUserID ¶
func (db *DB) SelectNotificationsByUserID(userID uint64) ([]*models.Notification, error)
SelectNotificationsByUserID returns a slice of Notifications by user ID from the database.
func (*DB) SelectSessionByKey ¶
SelectSessionByKey returns a single Session by key from the database.
func (*DB) SelectUserByID ¶
SelectUserByID returns a single User by ID from the database.
func (*DB) SelectUserByUsername ¶
SelectUserByUsername returns a single User by Username from the database.
func (*DB) UpdateNotification ¶
func (db *DB) UpdateNotification(n *models.Notification) error
UpdateNotification starts a transaction, updates the input Notification by its ID, and attempts to commit the transaction.
func (*DB) UpdateSession ¶
UpdateSession starts a transaction, updates the input Session by its ID, and attempts to commit the transaction.
func (*DB) UpdateUser ¶
UpdateUser starts a transaction, updates the input User by its ID, and attempts to commit the transaction.
type Rows ¶
Rows is a wrapped set of database rows, which provides additional methods for interacting directly with custom types.
func (*Rows) ScanNotifications ¶
func (r *Rows) ScanNotifications() ([]*models.Notification, error)
ScanNotifications returns a slice of Notifications from wrapped rows.
func (*Rows) ScanSessions ¶
ScanSessions returns a slice of Sessions from wrapped rows.
type Tx ¶
Tx is a wrapped database transaction, which provides additional methods for interacting directly with custom types.
func (*Tx) DeleteNotification ¶
func (tx *Tx) DeleteNotification(n *models.Notification) error
DeleteNotification updates the input Notification by its ID, in the context of the current transaction.
func (*Tx) DeleteNotificationsByUserID ¶
DeleteNotificationsByUserID deletes all Notifications with the input user ID, in the context of the current transaction.
func (*Tx) DeleteSession ¶
DeleteSession updates the input Session by its ID, in the context of the current transaction.
func (*Tx) DeleteSessionsByUserID ¶
DeleteSessionsByUserID deletes all Sessions with the input user ID, in the context of the current transaction.
func (*Tx) DeleteUser ¶
DeleteUser updates the input User by its ID, in the context of the current transaction.
func (*Tx) InsertNotification ¶
func (tx *Tx) InsertNotification(n *models.Notification) error
InsertNotification inserts a new Notification in the context of the current transaction.
func (*Tx) InsertSession ¶
InsertSession inserts a new Session in the context of the current transaction.
func (*Tx) InsertUser ¶
InsertUser inserts a new User in the context of the current transaction.
func (*Tx) UpdateNotification ¶
func (tx *Tx) UpdateNotification(n *models.Notification) error
UpdateNotification updates the input Notification by its ID, in the context of the current transaction.
func (*Tx) UpdateSession ¶
UpdateSession updates the input Session by its ID, in the context of the current transaction.