db

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2017 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const CtxKey = "_db"

CtxKey is the key which is used to store the *sql.DB instance inside context.Context.

Variables

This section is empty.

Functions

func CreateDongle

func CreateDongle(db *sql.DB, d *Dongle) error

func DB

func DB() (*sql.DB, error)

DB returns a ql backed database, with migrations already performed.

func DongleExists added in v0.1.8

func DongleExists(db *sql.DB, modem *Dongle) bool

DongleExists return true when the dongle DongleExists

func Migration

func Migration(db *sql.DB) error

Migration creates necessary database tables if they aint created yet.

func RemoveDongle

func RemoveDongle(db *sql.DB, d *Dongle) error

func UpdateDongle added in v0.1.2

func UpdateDongle(db *sql.DB, d *Dongle) error

Types

type Dongle

type Dongle struct {
	IMEI        string            `json:"imei"`
	IMSI        string            `json:"imsi"`
	Path        string            `json:"path"`
	IsSymlinked bool              `json:"symlink"`
	TTY         int               `json:"-"`
	ATI         string            `json:"ati"`
	Properties  map[string]string `json:"properties"`

	CreatedOn time.Time `json:"-"`
	UpdatedOn time.Time `json:"-"`
}

Dongle holds information about device dongles. This relies on combination from the information provided by udev and information that is gathered by talking to the device serial port directly.

func GetAllDongles

func GetAllDongles(db *sql.DB) ([]*Dongle, error)

func GetDistinct added in v0.1.3

func GetDistinct(db *sql.DB) ([]*Dongle, error)

func GetDongle

func GetDongle(db *sql.DB, path string) (*Dongle, error)

func GetDongleByIMEI added in v0.1.3

func GetDongleByIMEI(db *sql.DB, imei string) (*Dongle, error)

func GetSymlinkCandidate

func GetSymlinkCandidate(db *sql.DB, imei string) (*Dongle, error)

GetSymlinkCandidate returns the dongle with the lowest tty number

type Dongles added in v0.1.2

type Dongles []*Dongle

func (Dongles) Len added in v0.1.2

func (a Dongles) Len() int

func (Dongles) Less added in v0.1.2

func (a Dongles) Less(i, j int) bool

func (Dongles) Swap added in v0.1.2

func (a Dongles) Swap(i, j int)

Jump to

Keyboard shortcuts

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