Documentation ¶
Overview ¶
Package db provides a simplistic ORM to communicate with an SQL database for storage
Index ¶
- Constants
- type Database
- func (db *Database) AllocateIP(imsi string) (net.IP, error)
- func (db *Database) Backup() (string, error)
- func (db *Database) Close() error
- func (db *Database) CreateProfile(profile *Profile) error
- func (db *Database) CreateRadio(radio *Radio) error
- func (db *Database) CreateSubscriber(subscriber *Subscriber) error
- func (db *Database) CreateUser(user *User) error
- func (db *Database) DeleteProfile(name string) error
- func (db *Database) DeleteRadio(name string) error
- func (db *Database) DeleteSubscriber(imsi string) error
- func (db *Database) DeleteUser(email string) error
- func (db *Database) GetIPAddressesAllocated() (int, error)
- func (db *Database) GetIPAddressesTotal() (int, error)
- func (db *Database) GetOperator() (*Operator, error)
- func (db *Database) GetOperatorCode() (string, error)
- func (db *Database) GetProfile(name string) (*Profile, error)
- func (db *Database) GetProfileByID(id int) (*Profile, error)
- func (db *Database) GetRadio(name string) (*Radio, error)
- func (db *Database) GetSize() (int64, error)
- func (db *Database) GetSubscriber(imsi string) (*Subscriber, error)
- func (db *Database) GetUser(email string) (*User, error)
- func (db *Database) InitializeOperator() error
- func (db *Database) ListProfiles() ([]Profile, error)
- func (db *Database) ListRadios() ([]Radio, error)
- func (db *Database) ListSubscribers() ([]Subscriber, error)
- func (db *Database) ListUsers() ([]User, error)
- func (db *Database) NumUsers() (int, error)
- func (db *Database) ReleaseIP(imsi string) error
- func (db *Database) Restore(backupFilePath string) error
- func (db *Database) SubscribersInProfile(name string) (bool, error)
- func (db *Database) UpdateOperator(operator *Operator) error
- func (db *Database) UpdateOperatorCode(operatorCode string) error
- func (db *Database) UpdateProfile(profile *Profile) error
- func (db *Database) UpdateSubscriber(subscriber *Subscriber) error
- func (db *Database) UpdateUser(user *User) error
- type NumUsers
- type Operator
- type Profile
- type Radio
- type Subscriber
- type User
Constants ¶
View Source
const ( DefaultMcc = "001" DefaultMnc = "01" DefaultOperatorCode = "0123456789ABCDEF0123456789ABCDEF" DefaultSupportedTACs = `["001"]` DefaultOperatorSst = 1 DefaultOperatorSd = 1056816 )
View Source
const OperatorTableName = "operator"
View Source
const ProfilesTableName = "profiles"
View Source
const QueryCreateOperatorTable = `` /* 230-byte string literal not displayed */
View Source
const QueryCreateProfilesTable = `` /* 295-byte string literal not displayed */
View Source
const QueryCreateRadiosTable = `
CREATE TABLE IF NOT EXISTS %s (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL
)`
View Source
const QueryCreateSubscribersTable = `` /* 287-byte string literal not displayed */
View Source
const QueryCreateUsersTable = `` /* 131-byte string literal not displayed */
View Source
const RadiosTableName = "radios"
View Source
const SubscribersTableName = "subscribers"
View Source
const UsersTableName = "users"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
Database is the object used to communicate with the established repository.
func NewDatabase ¶
NewDatabase connects to a given table in a given database, stores the connection information and returns an object containing the information. The database path must be a valid file path or ":memory:". The table will be created if it doesn't exist in the format expected by the package.
func (*Database) CreateProfile ¶
func (*Database) CreateRadio ¶
func (*Database) CreateSubscriber ¶
func (db *Database) CreateSubscriber(subscriber *Subscriber) error
func (*Database) CreateUser ¶
func (*Database) DeleteProfile ¶
func (*Database) DeleteRadio ¶
func (*Database) DeleteSubscriber ¶
func (*Database) DeleteUser ¶
func (*Database) GetIPAddressesAllocated ¶
func (*Database) GetIPAddressesTotal ¶
func (*Database) GetOperator ¶ added in v0.0.5
func (*Database) GetOperatorCode ¶
func (*Database) GetSubscriber ¶
func (db *Database) GetSubscriber(imsi string) (*Subscriber, error)
func (*Database) InitializeOperator ¶
func (*Database) ListProfiles ¶
func (*Database) ListRadios ¶
func (*Database) ListSubscribers ¶
func (db *Database) ListSubscribers() ([]Subscriber, error)
ListSubscribers returns all of the subscribers and their fields available in the database.
func (*Database) SubscribersInProfile ¶ added in v0.0.5
func (*Database) UpdateOperator ¶ added in v0.0.5
func (*Database) UpdateOperatorCode ¶
func (*Database) UpdateProfile ¶
func (*Database) UpdateSubscriber ¶
func (db *Database) UpdateSubscriber(subscriber *Subscriber) error
func (*Database) UpdateUser ¶
type Operator ¶
type Operator struct { ID int `db:"id"` Mcc string `db:"mcc"` Mnc string `db:"mnc"` OperatorCode string `db:"operatorCode"` SupportedTACs string `db:"supportedTACs"` // JSON-encoded list of strings Sst int32 `db:"sst"` Sd int `db:"sd"` }
func (*Operator) GetSupportedTacs ¶ added in v0.0.5
func (*Operator) SetSupportedTacs ¶ added in v0.0.5
type Subscriber ¶
Click to show internal directories.
Click to hide internal directories.