models

package
v0.0.0-...-9a2d48e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 11, 2019 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Database

func Database(connString string) gin.HandlerFunc

Database : gin Middlware to select database

func DeletePeople

func DeletePeople(c *gin.Context)

func DeleteUser

func DeleteUser(c *gin.Context)

func DeleteVault

func DeleteVault(c *gin.Context)

DeleteVault : TODO verify there's no more field with this salt before delete

func GetPeople

func GetPeople(c *gin.Context)

func GetPeoples

func GetPeoples(c *gin.Context)

func GetUser

func GetUser(c *gin.Context)

func GetUsers

func GetUsers(c *gin.Context)

func GetVault

func GetVault(c *gin.Context)

GetVault : mainly to get VerifyKey

func GetVaults

func GetVaults(c *gin.Context)

GetVaults : get all vaults

func InitDb

func InitDb(dbName string) *gorp.DbMap

InitDb : create or update and connect to db on startup

func ParseQuery

func ParseQuery(q map[string][]string) (string, string, string)

ParseQuery : Parse a http query

func PostPeople

func PostPeople(c *gin.Context)

func PostUser

func PostUser(c *gin.Context)

func PostVault

func PostVault(c *gin.Context)

PostVault : create new vault

func TestValidSalt

func TestValidSalt(dbmap *gorp.DbMap, test string) bool

TestValidSalt : test if key is a valid salt in vaults

func UpdatePeople

func UpdatePeople(c *gin.Context)

func UpdateUser

func UpdateUser(c *gin.Context)

func UpdateVault

func UpdateVault(c *gin.Context)

UpdateVault : mainly store VerifyKey

Types

type People

type People struct {
	Id           int64     `db:"id" json:"id"`
	Name         string    `db:"name" json:"name"`
	XAddress     string    `db:"xaddress,size:65534" json:"xaddress"`
	XDateOfBirth string    `db:"xdob" json:"xdob"`
	Role         string    `db:"role" json:"role"`
	Status       string    `db:"status" json:"status"`
	Created      time.Time `db:"created" json:"created"` // or int64
	Updated      time.Time `db:"updated" json:"updated"`
}

XXX custom struct name and fields

func (*People) PreInsert

func (a *People) PreInsert(s gorp.SqlExecutor) error

func (*People) PreUpdate

func (a *People) PreUpdate(s gorp.SqlExecutor) error

type User

type User struct {
	Id      int64     `db:"id" json:"id"`
	Name    string    `db:"name" json:"name"`
	Email   string    `db:"email" json:"mail"`
	Status  string    `db:"status" json:"status"`
	Comment string    `db:"comment, size:65534" json:"comment"`
	Pass    string    `db:"pass" json:"pass"`
	Created time.Time `db:"created" json:"created"` // or int64
	Updated time.Time `db:"updated" json:"updated"`
}

XXX custom struct name and fields

func (*User) PreInsert

func (a *User) PreInsert(s gorp.SqlExecutor) error

func (*User) PreUpdate

func (a *User) PreUpdate(s gorp.SqlExecutor) error

type Vault

type Vault struct {
	Id        int64  `db:"id" json:"id"`
	VaultName string `db:"vaultname" json:"vaultname"`
	VerifyKey string `db:"verifykey" json:"verifykey"`
	// TODO:
	//  User
	//  UserEnckey
	//  Role  (su, admin, user, reader)
	//  Fragment (for su sss)
	Created time.Time `db:"created" json:"created"` // or int64
	Updated time.Time `db:"updated" json:"updated"`
}

Vault fields XXX custom struct name and fields

func (*Vault) PreInsert

func (a *Vault) PreInsert(s gorp.SqlExecutor) error

PreInsert : set create and update time

func (*Vault) PreUpdate

func (a *Vault) PreUpdate(s gorp.SqlExecutor) error

PreUpdate : set update time

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL