Documentation ¶
Index ¶
- Variables
- func Close()
- func Connect(dbType DBType, dbRoute string, schemaName string)
- func CreateTestData()
- func Heartbeat()
- func Setup()
- func Wipe() error
- type AuthSession
- type AuthSessionsTable
- func (ast *AuthSessionsTable) Delete(db *sql.DB, whereClause string) error
- func (ast *AuthSessionsTable) DeleteBySessionUUID(db *sql.DB, sessionUUID string) error
- func (ast *AuthSessionsTable) Init(db *sql.DB)
- func (ast *AuthSessionsTable) Insert(db *sql.DB, as *AuthSession) error
- func (ast *AuthSessionsTable) Name() string
- func (ast *AuthSessionsTable) Select(db *sql.DB, whatToSelect string, whereClause string) (*sql.Rows, error)
- func (ast *AuthSessionsTable) SelectBySessionUUID(db *sql.DB, sessionUUID string) (*AuthSession, error)
- func (ast *AuthSessionsTable) SelectByUserUUID(db *sql.DB, userUUID string) (*AuthSession, error)
- func (ast *AuthSessionsTable) Update(db *sql.DB, as *AuthSession) error
- type DBType
- type Field
- type Group
- type GroupMembership
- type GroupMembershipTable
- func (gmt *GroupMembershipTable) AddUserToGroup(db *sql.DB, u *User, groupTitle string) error
- func (gmt *GroupMembershipTable) DeleteAllUsersFromGroup(db *sql.DB, g *Group) (int64, error)
- func (gmt *GroupMembershipTable) DeleteUserFromGroup(db *sql.DB, u *User, g *Group) (int64, error)
- func (gmt *GroupMembershipTable) Init(db *sql.DB)
- func (gmt *GroupMembershipTable) Insert(db *sql.DB, gm *GroupMembership) error
- func (gmt *GroupMembershipTable) Name() string
- func (gmt *GroupMembershipTable) Select(db *sql.DB, whatToSelect string, whereClause string) (*sql.Rows, error)
- type GroupTable
- func (gt *GroupTable) DeleteByUUID(db *sql.DB, groupUUID string) (int64, error)
- func (gt *GroupTable) Init(db *sql.DB)
- func (gt *GroupTable) Insert(db *sql.DB, g *Group) error
- func (gt *GroupTable) Name() string
- func (gt *GroupTable) Select(db *sql.DB, whatToSelect string, whereClause string) (*sql.Rows, error)
- func (gt *GroupTable) SelectByTitle(db *sql.DB, groupTitle string) (*Group, error)
- func (gt *GroupTable) SelectByUUID(db *sql.DB, groupUUID string) (*Group, error)
- func (gt *GroupTable) Update(db *sql.DB, g *Group) error
- type Model
- type Page
- type PagesTable
- func (pt *PagesTable) DeleteByUUID(db *sql.DB, uuid string) (int64, error)
- func (pt *PagesTable) Init(db *sql.DB)
- func (pt *PagesTable) Insert(db *sql.DB, p *Page) error
- func (pt *PagesTable) Name() string
- func (pt *PagesTable) Select(db *sql.DB, whatToSelect string, whereClause string) (*sql.Rows, error)
- func (pt *PagesTable) SelectByRoute(db *sql.DB, route string) (*Page, error)
- func (pt *PagesTable) SelectByUUID(db *sql.DB, uuid string) (*Page, error)
- func (pt *PagesTable) Update(db *sql.DB, p *Page) error
- type SystemInfo
- type SystemInfoTable
- type Table
- type User
- type UserRole
- type UsersRoleFlag
- type UsersTable
- func (ut *UsersTable) DeleteByUUID(db *sql.DB, uuid string) (int64, error)
- func (ut *UsersTable) Init(db *sql.DB)
- func (ut *UsersTable) Insert(db *sql.DB, u *User) error
- func (ut *UsersTable) InsertMultiple(db *sql.DB, us []*User) error
- func (ut *UsersTable) Name() string
- func (ut *UsersTable) RootUserExists() bool
- func (ut *UsersTable) Select(db *sql.DB, whatToSelect string, whereClause string) (*sql.Rows, error)
- func (ut *UsersTable) SelectByUUID(db *sql.DB, uuid string) (*User, error)
- func (ut *UsersTable) SelectByUsername(db *sql.DB, username string) (*User, error)
- func (ut *UsersTable) SelectRootUser(db *sql.DB) (*User, error)
Constants ¶
This section is empty.
Variables ¶
var Conn *sql.DB
var SchemaName string
Functions ¶
func CreateTestData ¶
func CreateTestData()
CreateTestData fill database with known test data for development/testing purposes
Types ¶
type AuthSession ¶
type AuthSession struct { Authsessionid int `tbl:"AI" json:"authsessionid"` CreatedDateTime int64 `json:"createddatetime"` LastActiveDateTime int64 `json:"lastactivedatetime"` UserUUID string `json:"userUUID"` SessionUUID string `json:"sessionUUID"` }
func (*AuthSession) BuildFields ¶
func (as *AuthSession) BuildFields() []Field
func (*AuthSession) TableName ¶
func (as *AuthSession) TableName() string
func (*AuthSession) Validate ¶
func (as *AuthSession) Validate() bool
type AuthSessionsTable ¶
type AuthSessionsTable struct { Authsessionid int `tbl:"PKNNAIUI"` CreatedDateTime int64 `tbl:"NNDT"` LastActiveDateTime int64 `tbl:"NNDT"` UserUUID string `tbl:"NNUI"` SessionUUID string `tbl:"NNUI"` }
func (*AuthSessionsTable) Delete ¶
func (ast *AuthSessionsTable) Delete(db *sql.DB, whereClause string) error
func (*AuthSessionsTable) DeleteBySessionUUID ¶
func (ast *AuthSessionsTable) DeleteBySessionUUID(db *sql.DB, sessionUUID string) error
func (*AuthSessionsTable) Init ¶
func (ast *AuthSessionsTable) Init(db *sql.DB)
func (*AuthSessionsTable) Insert ¶
func (ast *AuthSessionsTable) Insert(db *sql.DB, as *AuthSession) error
func (*AuthSessionsTable) Name ¶
func (ast *AuthSessionsTable) Name() string
func (*AuthSessionsTable) SelectBySessionUUID ¶
func (ast *AuthSessionsTable) SelectBySessionUUID(db *sql.DB, sessionUUID string) (*AuthSession, error)
func (*AuthSessionsTable) SelectByUserUUID ¶
func (ast *AuthSessionsTable) SelectByUserUUID(db *sql.DB, userUUID string) (*AuthSession, error)
func (*AuthSessionsTable) Update ¶
func (ast *AuthSessionsTable) Update(db *sql.DB, as *AuthSession) error
Update - Takes auth session to update existing user session entry session UUID
type Field ¶
type Field struct { AutoIncrement bool PrimaryKey bool UniqueIndex bool IsDateTime bool NotNull bool Name string Type string Value interface{} // contains filtered or unexported fields }
Field interface to describe a table field and all of its attributes
type Group ¶
type Group struct { Groupid int `tbl:"AI" json:"groupid"` CreatedDateTime int64 `json:"createddatetime"` UUID string `json:"UUID"` Title string `json:"title"` }
func (*Group) BuildFields ¶
type GroupMembership ¶
type GroupMembership struct { Groupmembershipid int `tbl:"AI" json:"groupmembershipid"` CreatedDateTime int64 `json:"createddatetime"` GroupUUID string `json:"GroupUUID"` UserUUID string `json:"UserUUID"` }
func (*GroupMembership) BuildFields ¶
func (gm *GroupMembership) BuildFields() []Field
func (*GroupMembership) TableName ¶
func (gm *GroupMembership) TableName() string
type GroupMembershipTable ¶
type GroupMembershipTable struct { GroupMembershipid int `tbl:"PKNNAIUI"` CreatedDateTime int64 `tbl:"NN"` GroupUUID string `tbl:"NN"` UserUUID string `tbl:"NN"` }
func (*GroupMembershipTable) AddUserToGroup ¶
func (*GroupMembershipTable) DeleteAllUsersFromGroup ¶
func (*GroupMembershipTable) DeleteUserFromGroup ¶
func (*GroupMembershipTable) Init ¶
func (gmt *GroupMembershipTable) Init(db *sql.DB)
Init initialise table to include default memeberships
func (*GroupMembershipTable) Insert ¶
func (gmt *GroupMembershipTable) Insert(db *sql.DB, gm *GroupMembership) error
func (*GroupMembershipTable) Name ¶
func (gmt *GroupMembershipTable) Name() string
type GroupTable ¶
type GroupTable struct { Groupid int `tbl:"PKNNAIUI"` CreatedDateTime int64 `tbl:"NNDT"` UUID string `tbl:"NNUI"` Title string `tbl:"NNUI"` }
func (*GroupTable) DeleteByUUID ¶
func (*GroupTable) Init ¶
func (gt *GroupTable) Init(db *sql.DB)
func (*GroupTable) Name ¶
func (gt *GroupTable) Name() string
func (*GroupTable) SelectByTitle ¶
func (*GroupTable) SelectByUUID ¶
type Page ¶
type Page struct { PageId int `tbl:"AI" json:"pageid"` CreatedDateTime int64 `json:"createddatetime"` UUID string `json:"UUID"` Roleprotected bool `json:"roleprotected"` AuthorUUID string `json:"authoruuid"` Title string `json:"title"` Route string `json:"route"` Content string `json:"content"` }
func (*Page) BuildFields ¶
type PagesTable ¶
type PagesTable struct { Pageid int `tbl:"PKNNAIUI"` CreatedDateTime int64 `tbl:"NNDT"` UUID string `tbl:"NNUI"` Roleprotected bool `tbl:"NN"` AuthorUUID string `tbl:"NN"` Title string `tbl:"NNUI"` Route string `tbl:"NNUI"` Content string `tbl:"NN"` }
func (*PagesTable) DeleteByUUID ¶
func (*PagesTable) Init ¶
func (pt *PagesTable) Init(db *sql.DB)
func (*PagesTable) Name ¶
func (pt *PagesTable) Name() string
func (*PagesTable) SelectByRoute ¶
TODO: Should really consider changing this to call the existing select func
func (*PagesTable) SelectByUUID ¶
type SystemInfo ¶
type SystemInfo struct {
Version string `json:"version"`
}
func (*SystemInfo) BuildFields ¶
func (si *SystemInfo) BuildFields() []Field
func (*SystemInfo) TableName ¶
func (si *SystemInfo) TableName() string
type SystemInfoTable ¶
type SystemInfoTable struct {
Version string `tbl:NN`
}
func (*SystemInfoTable) Init ¶
func (sit *SystemInfoTable) Init(db *sql.DB)
func (*SystemInfoTable) Insert ¶
func (sit *SystemInfoTable) Insert(db *sql.DB, systemInfo *SystemInfo) error
func (*SystemInfoTable) Name ¶
func (sit *SystemInfoTable) Name() string
func (*SystemInfoTable) Update ¶
func (sit *SystemInfoTable) Update(db *sql.DB, as *SystemInfo) error
type User ¶
type User struct { UserId int `tbl:"AI" json:"userid"` CreatedDateTime int64 `json:"createddatetime"` UserroleId int `json:"userroleid"` UUID string `json:"UUID"` Username string `json:"username"` AuthHash string `json:"authhash"` FirstName string `json:"firstname"` LastName string `json:"lastname"` Email string `json:"email"` }
User describes the content of a user, it should match the columns present in the users table
func (*User) BuildFields ¶
BuildFields generates a list of fields generated from the fields of the user struct
func (*User) Login ¶
Login takes the current username and authhash values of self and tries using them to authenticate/login. A successful login will return/generate a JWT token for further use in any subsequent API request
type UserRole ¶
UserRole describes the content of a userrole entry, it should match the columns present in the userrole table
func (*UserRole) BuildFields ¶
BuildFields generates a list of fields generated from the fields of the userrole struct
type UsersRoleFlag ¶
type UsersRoleFlag int
const ( ROOT_USER UsersRoleFlag = 2 MOD_USER UsersRoleFlag = 3 REG_USER UsersRoleFlag = 4 )
type UsersTable ¶
type UsersTable struct { Userid int `tbl:"PKNNAIUI"` CreatedDateTime int64 `tbl:"NNDT"` Userroleid int `tbl:"NN"` UUID string `tbl:"NNUI"` Username string `tbl:"NNUI"` Authhash string `tbl:"NN"` Firstname string `tbl:"NN"` Lastname string `tbl:"NN"` Email string `tbl:"NNUI"` }
UsersTable describes the table structure for UsersTable in db
func (*UsersTable) DeleteByUUID ¶
func (*UsersTable) Init ¶
func (ut *UsersTable) Init(db *sql.DB)
Init carries out default data entry
func (*UsersTable) Insert ¶
func (ut *UsersTable) Insert(db *sql.DB, u *User) error
Insert adds user struct to users table, it also sets default values
func (*UsersTable) InsertMultiple ¶
func (ut *UsersTable) InsertMultiple(db *sql.DB, us []*User) error
InsertMultiple takes a slice of user structs and passes them all to 'Insert'
func (*UsersTable) Name ¶
func (ut *UsersTable) Name() string
Name gets the table name, have to implement to make UsersTable inherit Table
func (*UsersTable) RootUserExists ¶
func (ut *UsersTable) RootUserExists() bool
RootUserExists checks if at least one root user exists
func (*UsersTable) Select ¶
func (ut *UsersTable) Select(db *sql.DB, whatToSelect string, whereClause string) (*sql.Rows, error)
Select returns table rows from a select using the passed where condition
func (*UsersTable) SelectByUUID ¶
func (*UsersTable) SelectByUsername ¶
func (*UsersTable) SelectRootUser ¶
func (ut *UsersTable) SelectRootUser(db *sql.DB) (*User, error)