Documentation ¶
Index ¶
- Constants
- func Count(store *db.DB, table string) (int, error)
- func CreateSession(store *db.DB, s *Session) error
- func CreateUser(store *db.DB, u *User) error
- func DeleteSession(store *db.DB, s *Session) error
- func ExecModel(store *db.DB, model interface{}, query db.Query) (sql.Result, error)
- func HashPassword(pass []byte) ([]byte, error)
- func QueryRowModel(store *db.DB, model interface{}, query db.Query) *sql.Row
- func Sanitize(src string) string
- func UpdateSession(store *db.DB, s *Session) error
- func VerifyPass(hash, pass []byte) error
- type BuildArtifact
- type BuildTask
- type Config
- type Context
- type Project
- type Session
- type User
Constants ¶
const ( //CtxBuild is the key that stores Context in all the requests. CtxBuild = "buildCtx" //TaskTable is the name of the database table for tasks. TaskTable = "tasks" //SessionTable is the name of the database table for sessions SessionTable = "sessions" //UserTable is the name of the databse table for users. UserTable = "users" //DBTag is the name of the struct tag used by the store DBTag = "store" )
Variables ¶
This section is empty.
Functions ¶
func CreateSession ¶
CreateSession creates a new database record for the session s object. This sets CreatedOn and UpdatedOn fieds to time.Now().
func CreateUser ¶
CreateUser creates a new record in the userstable. The Password field is hashed before being stored. The Username is sanitized before storing it to the database( Don't trust abybody).
func DeleteSession ¶
DeleteSession deletes a session record which matches key.
func ExecModel ¶
ExecModel executes the given query. If the guery requires data from the model then the data is also taken care of.
This provides a simple abstraction for repetitive dababase query execution. It supports transactions.
func HashPassword ¶
HashPassword hash pass using bcrypt.
func QueryRowModel ¶
QueryRowModel use the model to query for one row.
func UpdateSession ¶
UpdateSession updates a ratabase record for session whose key matches key. Only two fields are updated, the data and updated_on field.
func VerifyPass ¶
VerifyPass verifies that the hash is the hash of pass using bcrypt.
Types ¶
type BuildArtifact ¶
BuildArtifact is an interface which defines a buildable command.
type BuildTask ¶
type BuildTask struct { ID int64 `store:"id"` UUID string `store:"uuid"` Done bool `store:"done"` User int64 `store:"user_id"` Project int64 `store:"project_id"` Source string `store:"source"` CreatedAt time.Time `store:"created_on"` UpdateAt time.Time `store:"updated_on"` }
BuildTask is a task for building a project.
type Context ¶
Context holda important information that can be used by diffenet components of the application.
type Project ¶
type Project struct { ID int `store:"id"` Name string `store:"name"` UserID int `store:"user_id"` CreatedAt time.Time `store:"created_at"` UpdatedAt time.Time `store:"updated_at"` }
Project represent a project.
type Session ¶
type Session struct { Key string `store:"key"` Data []byte `store:"data"` CreatedOn time.Time UpdatedOn time.Time ExpiresOn time.Time `store:"expires_on"` }
Session stores http session information.
type User ¶
type User struct { ID int64 `store:"id"` Name string `store:"username"` Email string `store:"email"` Password []byte `store:"password"` CreatedAt time.Time `store:"created_on"` UpdatedAt time.Time `store:"updated_on"` }
User represent the application user. It stores important information about the user.
The Name, Email and ID fields are all unique. Password is a hashed password, hashed using bcrypt algorithm.