db

package
v0.0.0-...-1f1fe6b Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Close

func Close()

Close closes the database and prevents new queries from starting.

func CreateTable

func CreateTable() (err error)

CreateTable runs a query to create a table to store phone number data.

func DeleteNumber

func DeleteNumber(phn PhoneNumber, msg string) (err error)

DeleteNumber deletes given phone number from database

func InsertNumber

func InsertNumber(value string) (uid int64, err error)

InsertNumber inserts given phone number into database and returns uid.

func Normalize

func Normalize(numbers []PhoneNumber) error

Normalize iterates over all the numbers from database and normalizes them.

func Open

func Open() (err error)

Open creates a new sqlite database file, returns the pointer to database.

func UpdateNumber

func UpdateNumber(phn PhoneNumber, new string) (err error)

UpdateNumber updates new val at given uid, else returns error.

Types

type PhoneNumber

type PhoneNumber struct {
	Uid int64
	Val string
}

PhoneNumber is Go representation for phone_number table in database.

func FindNumber

func FindNumber(val string) (*PhoneNumber, error)

FindNumber looks up given number in database and returns matched row

func SelectAll

func SelectAll() ([]PhoneNumber, error)

SelectAll fetches all the rows from phone_numbers table.

func (PhoneNumber) Format

func (pn PhoneNumber) Format() string

Format displays the phone number in "(223) 456-7890" format.

Jump to

Keyboard shortcuts

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