コード例 #1
0
func (e *Log) Insert(db ab.DB) error {
	// HOOK: beforeLogInsert()

	err := db.QueryRow("INSERT INTO \"log\"(type, message, created) VALUES($1, $2, $3) RETURNING uuid", e.Type, e.Message, e.Created).Scan(&e.UUID)

	// HOOK: afterLogInsert()

	return err
}
コード例 #2
0
func (e *User) Insert(db ab.DB) error {
	// HOOK: beforeUserInsert()

	err := db.QueryRow("INSERT INTO \"user\"(name, mail, admin, created, lastseen) VALUES($1, $2, $3, $4, $5) RETURNING uuid", e.Name, e.Mail, e.Admin, e.Created, e.LastSeen).Scan(&e.UUID)

	// HOOK: afterUserInsert()

	return err
}
コード例 #3
0
func (e *Walkthrough) Insert(db ab.DB) error {
	beforeWalkthroughInsert(e)

	jsonSteps := ""

	bjsonSteps, _ := json.Marshal(e.Steps)
	jsonSteps = string(bjsonSteps)
	err := db.QueryRow("INSERT INTO \"walkthrough\"(uuid, uid, name, description, severity, steps, updated, published) VALUES($1, $2, $3, $4, $5, $6, $7, $8) RETURNING revision", e.UUID, e.UID, e.Name, e.Description, e.Severity, jsonSteps, e.Updated, e.Published).Scan(&e.Revision)

	// HOOK: afterWalkthroughInsert()

	return err
}