Documentation ¶
Index ¶
- Constants
- type Story
- func Select(db *sql.DB, additionalClauses string, bindValues ...interface{}) (results []Story, err error)
- func SelectAll(db *sql.DB) ([]Story, error)
- func SelectRow(db *sql.DB, additionalClauses string, bindValues ...interface{}) (Story, error)
- func SelectTx(tx *sql.Tx, additionalClauses string, bindValues ...interface{}) ([]Story, error)
- func (r *Story) Delete(db *sql.DB) (rowCount int64, err error)
- func (r *Story) DeleteTx(tx *sql.Tx) (rowCount int64, err error)
- func (r Story) Insert(db *sql.DB) (newR Story, err error)
- func (r Story) InsertTx(tx *sql.Tx) (Story, error)
- func (s *Story) PreInsert(tx *sql.Tx, tableName string) error
- func (s *Story) PreUpdate(tx *sql.Tx, tableName string) error
- func (r Story) Update(db *sql.DB) (newR Story, err error)
- func (r Story) UpdateTx(tx *sql.Tx) (Story, error)
Constants ¶
const (
TableName = "stories"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Story ¶
type Story struct { ID int64 `db:"id" crud:"autoincr"` URL string `db:"url"` MP3URL string `db:"mp3_url"` MP3Duration sql.NullInt64 `db:"mp3_duration"` Name string `db:"name"` Description string `db:"description"` CreatedAt time.Time `db:"created_at" crud:"create_timestamp"` UpdatedAt time.Time `db:"updated_at" crud:"update_timestamp"` // contains filtered or unexported fields }
Story has details about a single story.
func Select ¶
func Select(db *sql.DB, additionalClauses string, bindValues ...interface{}) (results []Story, err error)
Select wraps SelectTx in a transaction.
func SelectRow ¶
SelectRow will select one record from table stories and return a Story. The additionalClauses argument should be SQL to be appended to the "select ... from stories" statement, using "?" for bind variables. E.g. "where foo = ?". bindValues must be provided in the correct order to match bind placeholders in the additionalClauses. Returns sql.ErrNoRows if no rows found.
func SelectTx ¶
SelectTx will select records from table stories and return a slice of Story. The additionalClauses argument should be SQL to be appended to the "select ... from stories" statement, using "?" for bind variables. E.g. "where foo = ?". bindValues must be provided in the correct order to match bind placeholders in the additionalClauses.
func (*Story) DeleteTx ¶
DeleteTx executes PreDelete, delete, and PostDelete within a transaction. Will fail if delete affects more than one row. No error if 0 rows are deleted.
func (Story) InsertTx ¶
InsertTx will insert on Story, given a transaction. Invokes PreInsert and PostInsert hooks. Returns new Story with ID, timestamps, etc updated.