Documentation
¶
Index ¶
- func GetTimeUTCPointer() *time.Time
- func IsUnixZero(t time.Time) bool
- func RandString(n int) string
- func TimeToPointer(t time.Time) *time.Time
- func UnixToTimePointer(v int64) *time.Time
- type DBConf
- type Database
- type Item
- type ListStatus
- type TodoItem
- type TodoItemStore
- func (store TodoItemStore) FindAll(cond ...interface{}) ([]*TodoItem, error)
- func (store TodoItemStore) FindByID(ID int64) (*TodoItem, error)
- func (store TodoItemStore) FindOne(cond ...interface{}) (*TodoItem, error)
- func (store TodoItemStore) UpdateByID(ID int64, todoitem *TodoItem) (*TodoItem, error)
- type TodoList
- type TodoListItems
- type TodoListStore
- type TodoStatus
- type User
- type UserEtc
- type UserRole
- type UsersStore
- func (store UsersStore) FindAll(cond ...interface{}) ([]*User, error)
- func (store UsersStore) FindByAlias(alias string) (*User, error)
- func (store UsersStore) FindByEmail(email string) (*User, error)
- func (store UsersStore) FindByID(ID int64) (*User, error)
- func (store UsersStore) FindOne(cond ...interface{}) (*User, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetTimeUTCPointer ¶
GetTimeUTCPointer gets utc time pointer
func IsUnixZero ¶
func RandString ¶
RandString generates random sting from characters in letters
func UnixToTimePointer ¶
Types ¶
type DBConf ¶
type DBConf struct {
Database string `toml:"database"`
Hosts []string `toml:"hosts"`
Username string `toml:"username"`
Password string `toml:"password"`
DebugQueries bool `toml:"debug_queries"`
ApplicationName string `toml:"application_name"`
MaxConnection int `toml:"max_connection"`
SSLMode string `toml:"ssl_mode"`
DatabaseURL string `env:"DATABASE_URL"`
}
DBConf database configuration
type Database ¶
type Database struct {
db.Session
User *UsersStore
TodoList *TodoListStore
TodoItem *TodoItemStore
}
Database holds database postgres table structure
var DB *Database
DB is a pointer to the database interface
type Item ¶
type Item struct {
ID int64 `db:"id" json:"id"`
TodoListID int64 `db:"todo_list_id" json:"todo_list_id"`
Title string `db:"title" json:"title"`
Todo string `db:"todo" json:"todo"`
Comment string `db:"comment" json:"comment"`
ListStatus ListStatus `db:"list_status" json:"list_status"`
ItemStatus TodoStatus `db:"todo_status" json:"todo_status"`
}
type ListStatus ¶
type ListStatus string
ListStatus is list status
const ( // ListStatusActive is todo_list status active ListStatusActive ListStatus = "active" // ListStatusCompleted is todo_list status completed ListStatusCompleted ListStatus = "completed" // ListStatusCancelled is todo_list status cancelled ListStatusCancelled ListStatus = "cancelled" )
type TodoItem ¶
type TodoItem struct {
ID int64 `db:"id,omitempty" json:"id"`
TodoListID int64 `db:"todo_list_id,omitempty" json:"todo_list_id"`
Status TodoStatus `db:"status" json:"status"`
Todo string `db:"todo,omitempty" json:"todo"`
Comment string `db:"comment,omitempty" json:"comment"`
CreatedAt *time.Time `db:"created_at,omitempty" json:"createdAt"`
UpdatedAt *time.Time `db:"updated_at,omitempty" json:"updatedAt"`
}
TodoItem holds postgres data structure for todo_item
func (*TodoItem) BeforeCreate ¶
BeforeCreate retrives and sets GetTimeUTCPointer before creating a new todoitem
func (*TodoItem) BeforeUpdate ¶
BeforeUpdate retrives and sets GetTimeUTCPointer before updating a todoitem
type TodoItemStore ¶
type TodoItemStore struct {
db.Collection
}
TodoItemStore holds thread todoitem database collection
func (TodoItemStore) FindAll ¶
func (store TodoItemStore) FindAll(cond ...interface{}) ([]*TodoItem, error)
FindAll retrieves todoitems by certain conditions from TodoItemStore
func (TodoItemStore) FindByID ¶
func (store TodoItemStore) FindByID(ID int64) (*TodoItem, error)
FindByID retrieves a particular todoitem by id
func (TodoItemStore) FindOne ¶
func (store TodoItemStore) FindOne(cond ...interface{}) (*TodoItem, error)
FindOne retrieves todoitem by certain conditions from TodoItemStore
func (TodoItemStore) UpdateByID ¶
func (store TodoItemStore) UpdateByID(ID int64, todoitem *TodoItem) (*TodoItem, error)
UpdateByID retrieves and updates todoitem by id
type TodoList ¶
type TodoList struct {
ID int64 `db:"id,omitempty" json:"id"`
Status ListStatus `db:"status,omitempty" json:"status"`
Title string `db:"title,omitempty" json:"title"`
CreatedAt *time.Time `db:"created_at,omitempty" json:"createdAt"`
UpdatedAt *time.Time `db:"updated_at,omitempty" json:"updatedAt"`
}
TodoList holds postgres data structure for todo_list
func (*TodoList) BeforeCreate ¶
BeforeCreate retrives and sets GetTimeUTCPointer before creating a new todolist
func (*TodoList) BeforeUpdate ¶
BeforeUpdate retrives and sets GetTimeUTCPointer before updating a todolist
type TodoListItems ¶
type TodoListItems []Item
func (*TodoListItems) Render ¶
func (u *TodoListItems) Render(w http.ResponseWriter, r *http.Request) error
type TodoListStore ¶
type TodoListStore struct {
db.Collection
}
TodoListStore holds thread todolist database collection
func (TodoListStore) FindAll ¶
func (store TodoListStore) FindAll(cond ...interface{}) ([]*TodoList, error)
FindAll retrieves todolists by certain conditions from TodoListStore
func (TodoListStore) FindByID ¶
func (store TodoListStore) FindByID(ID int64) (*TodoListItems, error)
FindByID retrieves a particular todolist by id
func (TodoListStore) FindOne ¶
func (store TodoListStore) FindOne(cond ...interface{}) (*TodoList, error)
FindOne retrieves todolist by certain conditions from TodoListStore
type TodoStatus ¶
type TodoStatus string
TodoStatus is todo status
const ( // TodoStatusActive is todo_item status active TodoStatusActive TodoStatus = "active" // TodoStatusCompleted is todo_item status completed TodoStatusCompleted TodoStatus = "completed" // TodoStatusCancelled is todo_item status cancelled TodoStatusCancelled TodoStatus = "cancelled" )
type User ¶
type User struct {
ID int64 `db:"id,omitempty" json:"id"`
Email string `db:"email,omitempty" json:"email"`
PasswordHash string `db:"password_hash,omitempty" json:"-"`
Role UserRole `db:"role" json:"role"`
FirstName string `db:"first_name,omitempty" json:"firstName"`
LastName string `db:"last_name,omitempty" json:"lastName"`
Location string `db:"location,omitempty" json:"location"`
Etc UserEtc `db:"etc,omitempty" json:"etc"`
CreatedAt *time.Time `db:"created_at,omitempty" json:"createdAt"`
UpdatedAt *time.Time `db:"updated_at,omitempty" json:"updatedAt"`
// Display Only
Biography string `json:"biography"`
Name string `json:"name"`
}
User holds postgres data structure for user
func (*User) BeforeCreate ¶
BeforeCreate retrives and sets GetTimeUTCPointer before creating a new user
func (*User) BeforeUpdate ¶
BeforeUpdate retrives and sets GetTimeUTCPointer before updating a user
type UserEtc ¶
type UserEtc struct {
HasProfile bool
*postgresql.JSONBConverter
}
UserEtc is a collection of auxillary key/values around a user
type UsersStore ¶
type UsersStore struct {
db.Collection
}
UsersStore holds thread users database collection
func (UsersStore) FindAll ¶
func (store UsersStore) FindAll(cond ...interface{}) ([]*User, error)
FindAll retrieves users by certain conditions from UsersStore
func (UsersStore) FindByAlias ¶
func (store UsersStore) FindByAlias(alias string) (*User, error)
FindByAlias retrieves a particular user by alias
func (UsersStore) FindByEmail ¶
func (store UsersStore) FindByEmail(email string) (*User, error)
FindByEmail retrieves a particular user by email
func (UsersStore) FindByID ¶
func (store UsersStore) FindByID(ID int64) (*User, error)
FindByID retrieves a particular user by id
func (UsersStore) FindOne ¶
func (store UsersStore) FindOne(cond ...interface{}) (*User, error)
FindOne retrieves user by certain conditions from UsersStore