Documentation
¶
Index ¶
- Variables
- func PrintQuery(query string, args ...interface{})
- func PrintResult(i interface{})
- type DBError
- type DBOption
- type DBResult
- type DBService
- func (u DBService) Del(i interface{}) *DBError
- func (u DBService) Delete(sql string, id int64) *DBError
- func (u DBService) FindByID(tableName string, id int64, i interface{}) (interface{}, *DBError)
- func (u DBService) FindByName(tableName string, name string, i interface{}) (interface{}, *DBError)
- func (u DBService) Insert(tableName string, i interface{}) (sql.Result, *DBError)
- func (u DBService) List(tableName string, dest interface{}) *DBError
- func (u DBService) ListBy(tableName string, dest interface{}, where string, args ...interface{}) *DBError
- func (u DBService) MustExec(sql string, args ...interface{}) *DBError
- func (u DBService) NamedExec(sql string, obj interface{}) (sql.Result, *DBError)
- func (u DBService) PrepareNamed(sql string, arg interface{}) (sql.Result, *DBError)
- func (u DBService) Save(i interface{}) *DBError
- func (u DBService) Select(dest interface{}, query string, args ...interface{}) (interface{}, *DBError)
- type Mappable
- type MappingConfig
- type RuntimeInstall
- type User
- type UserService
- func (u UserService) FindAllRuntimeInstallsForUser(dest interface{}, username string) *DBError
- func (u UserService) FindBy(i interface{}, where string, args ...interface{}) *DBError
- func (u UserService) FindUserByGoogleID(googleIDHashed string) (User, *DBError)
- func (u UserService) UpdateGoogleID(user User) (sql.Result, *DBError)
- func (u UserService) UpdateProfile(user User) (sql.Result, *DBError)
Constants ¶
This section is empty.
Variables ¶
var CreateSchema = `` /* 2093-byte string literal not displayed */
CreateSchema SQL script for creating the schema
var DropSchema = `
DROP TABLE IF EXISTS runtime_install CASCADE;
DROP TABLE IF EXISTS users CASCADE;
`
DropSchema SQL script for dropping the schema
Functions ¶
func PrintQuery ¶ added in v0.2.1
func PrintQuery(query string, args ...interface{})
PrintQuery prints query
Types ¶
type DBError ¶
DBError database error
type DBOption ¶ added in v0.2.10
type DBOption func(*DBService)
DBOption db option
func DBOptionDebug ¶ added in v0.2.10
DBOptionDebug db option debug
type DBResult ¶
type DBResult struct {
// contains filtered or unexported fields
}
DBResult for capturing result information for inserts
func (DBResult) LastInsertId ¶
LastInsertId last inserted id
func (DBResult) RowsAffected ¶
RowsAffected number of rows affected
type DBService ¶
DBService db service
func NewDBService ¶
NewDBService instantiates new db service
func (DBService) FindByName ¶ added in v0.2.0
FindByName finds by name
func (DBService) ListBy ¶ added in v0.2.0
func (u DBService) ListBy(tableName string, dest interface{}, where string, args ...interface{}) *DBError
ListBy lists all rows of given entity with where clause
func (DBService) PrepareNamed ¶
PrepareNamed wrapper for sqlx.PrepareNamed. However, it handles retrieval of new id
type Mappable ¶ added in v0.2.0
type Mappable interface {
Meta() MappingConfig
PrimaryKey() int64
SetPrimaryKey(int64)
}
Mappable structs returns sql specific meta data
type MappingConfig ¶ added in v0.2.0
type MappingConfig struct {
TableName string
}
MappingConfig provides addtional hints to DBService
func GetMappingConfigFromSlicePointer ¶ added in v0.2.0
func GetMappingConfigFromSlicePointer(dest interface{}) *MappingConfig
GetMappingConfigFromSlicePointer gets mapping config from slice pointer
type RuntimeInstall ¶
type RuntimeInstall struct {
ID int64 `db:"id"`
Name string `db:"name"`
ScriptBody string `db:"script_body"`
}
RuntimeInstall runtime install
func (RuntimeInstall) Meta ¶ added in v0.2.0
func (ri RuntimeInstall) Meta() MappingConfig
Meta provides mapping config specific to runtime install
func (RuntimeInstall) PrimaryKey ¶ added in v0.2.0
func (ri RuntimeInstall) PrimaryKey() int64
PrimaryKey returns primary key
func (RuntimeInstall) SetPrimaryKey ¶ added in v0.2.0
func (ri RuntimeInstall) SetPrimaryKey(id int64)
SetPrimaryKey updates the primary key value after insert
func (RuntimeInstall) String ¶ added in v0.3.0
func (ri RuntimeInstall) String() string
type User ¶
type User struct {
ID int64 `db:"id"`
GoogleID string `db:"google_id"`
Username string `db:"username"`
Password string `db:"password"`
Email string `db:"email"`
HashedEmail string `db:"hashed_email"`
IsActive bool `db:"is_active"`
PrivateKey string `db:"private_key"`
PublicKey string `db:"public_key"`
PublicKeyID int64 `db:"public_key_id"`
GitRepoURI string `db:"git_repo_uri"`
IDE string `db:"ide"`
RuntimeInstalls string `db:"runtime_installs"`
DockerTag string
Installed []RuntimeInstall
PostgresUsername string
PGHost string
PGDBName string
}
User user
func (*User) Meta ¶ added in v0.2.0
func (u *User) Meta() MappingConfig
Meta provides mapping config specific to user
func (*User) PrimaryKey ¶ added in v0.2.0
PrimaryKey returns primary key
func (*User) SetPrimaryKey ¶ added in v0.2.0
SetPrimaryKey updates the primary key value after insert
type UserService ¶
type UserService struct {
*DBService
}
UserService manages user data
func NewUserService ¶
func NewUserService(db *sqlx.DB) UserService
NewUserService instantiates new user service
func NewUserServiceWithOptions ¶ added in v0.2.10
func NewUserServiceWithOptions(db *sqlx.DB, options ...DBOption) UserService
NewUserServiceWithOptions returns new user service with options
func (UserService) FindAllRuntimeInstallsForUser ¶ added in v0.3.0
func (u UserService) FindAllRuntimeInstallsForUser(dest interface{}, username string) *DBError
FindUserIDERuntimeInstallsByUsernameAndIDE finds user installs by user and ide
func (UserService) FindBy ¶ added in v0.2.0
func (u UserService) FindBy(i interface{}, where string, args ...interface{}) *DBError
FindBy finds ide by given where clause
func (UserService) FindUserByGoogleID ¶
func (u UserService) FindUserByGoogleID(googleIDHashed string) (User, *DBError)
FindUserByGoogleID finds user by google id
func (UserService) UpdateGoogleID ¶
func (u UserService) UpdateGoogleID(user User) (sql.Result, *DBError)
UpdateGoogleID updates user google id
func (UserService) UpdateProfile ¶
func (u UserService) UpdateProfile(user User) (sql.Result, *DBError)
UpdateProfile updates user profile