story

package
Version: v0.0.0-...-7392356 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 22, 2018 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
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 SelectAll

func SelectAll(db *sql.DB) ([]Story, error)

SelectAll does a Select with no additional conditions/clauses.

func SelectRow

func SelectRow(db *sql.DB, additionalClauses string, bindValues ...interface{}) (Story, error)

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

func SelectTx(tx *sql.Tx, additionalClauses string, bindValues ...interface{}) ([]Story, error)

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) Delete

func (r *Story) Delete(db *sql.DB) (rowCount int64, err error)

Wraps DeleteTx() in a transaction.

func (*Story) DeleteTx

func (r *Story) DeleteTx(tx *sql.Tx) (rowCount int64, err error)

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) Insert

func (r Story) Insert(db *sql.DB) (newR Story, err error)

Insert wraps InsertTx() in a transaction.

func (Story) InsertTx

func (r Story) InsertTx(tx *sql.Tx) (Story, error)

InsertTx will insert on Story, given a transaction. Invokes PreInsert and PostInsert hooks. Returns new Story with ID, timestamps, etc updated.

func (*Story) PreInsert

func (s *Story) PreInsert(tx *sql.Tx, tableName string) error

PreInsert runs before inserting a row.

func (*Story) PreUpdate

func (s *Story) PreUpdate(tx *sql.Tx, tableName string) error

PreUpdate runs before updating a row.

func (Story) Update

func (r Story) Update(db *sql.DB) (newR Story, err error)

Wraps UpdateTx() in a transaction.

func (Story) UpdateTx

func (r Story) UpdateTx(tx *sql.Tx) (Story, error)

UpdateTx will update a row, given a transaction. Will fail and return an error if not exactly 1 row is updated. Returns new Story with timestamps, etc updated.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL