func selectWalkthroughFromQuery(db ab.DB, query string, args ...interface{}) ([]*Walkthrough, error) {
	// HOOK: beforeWalkthroughSelect()

	entities := []*Walkthrough{}

	rows, err := db.Query(query, args...)

	if err != nil {
		return entities, err
	}

	for rows.Next() {
		e := EmptyWalkthrough()
		jsonSteps := ""

		if err = rows.Scan(&e.Revision, &e.UUID, &e.UID, &e.Name, &e.Description, &e.Severity, &jsonSteps, &e.Updated, &e.Published); err != nil {
			return []*Walkthrough{}, err
		}

		json.Unmarshal([]byte(jsonSteps), &e.Steps)

		entities = append(entities, e)
	}

	// HOOK: afterWalkthroughSelect()

	return entities, err
}
示例#2
0
func selectLogFromQuery(db ab.DB, query string, args ...interface{}) ([]*Log, error) {
	// HOOK: beforeLogSelect()

	entities := []*Log{}

	rows, err := db.Query(query, args...)

	if err != nil {
		return entities, err
	}

	for rows.Next() {
		e := EmptyLog()

		if err = rows.Scan(&e.UUID, &e.Type, &e.Message, &e.Created); err != nil {
			return []*Log{}, err
		}

		entities = append(entities, e)
	}

	// HOOK: afterLogSelect()

	return entities, err
}
示例#3
0
func selectUserFromQuery(db ab.DB, query string, args ...interface{}) ([]*User, error) {
	// HOOK: beforeUserSelect()

	entities := []*User{}

	rows, err := db.Query(query, args...)

	if err != nil {
		return entities, err
	}

	for rows.Next() {
		e := EmptyUser()

		if err = rows.Scan(&e.UUID, &e.Name, &e.Mail, &e.Admin, &e.Created, &e.LastSeen); err != nil {
			return []*User{}, err
		}

		entities = append(entities, e)
	}

	// HOOK: afterUserSelect()

	return entities, err
}