models

package
v0.0.0-...-c6e3130 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2022 License: Apache-2.0 Imports: 2 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// PersonTableName is the name of the table for the person model
	PersonTableName = "person"
	// PersonFirstNameCol is the column name of the model's first name
	PersonFirstNameCol = "first_name"
	// PersonLastNameCol is the column name of the model's last name
	PersonLastNameCol = "last_name"
	// PersonAgeCol is the column name of the model's age
	PersonAgeCol = "age"
)

Variables

This section is empty.

Functions

func CreatePersonTable

func CreatePersonTable(db *sql.DB) (sql.Result, error)

CreatePersonTable uses db to create a new table for Person models, and returns the result

func DeletePerson

func DeletePerson(db *sql.DB, firstName, lastName string, age uint) error

DeletePerson deletes the person with the given first & last names and age. Returns a non-nil error if the delete failed, and nil if the delete succeeded

func InsertPerson

func InsertPerson(db *sql.DB, person Person) (sql.Result, error)

InsertPerson inserts person into db

func SelectPerson

func SelectPerson(db *sql.DB, firstName, lastName string, age uint, result *Person) error

SelectPerson selects a person with the given first & last names and age. On success, writes the result into result and on failure, returns a non-nil error and makes no modifications to result

func UpdatePerson

func UpdatePerson(db *sql.DB, firstName, lastName string, age uint, newPerson Person) error

UpdatePerson updates the person with the given first & last names and age with newPerson. Returns a non-nil error if the update failed, and nil if the update succeeded

Types

type Person

type Person struct {
	FirstName string
	LastName  string
	Age       uint
}

Person is the database model for a person

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL