func (db *DB) CreateFlag(flag api.AdminFlagPost) (int64, error) {
	id := int64(-1)
	err := db.QueryRow("INSERT INTO flag (flag, value, return_string, description, tags) VALUES ($1, $2, $3, $4, $5) RETURNING id",
		flag.Flag, flag.Value, flag.ReturnString, flag.Description, utils.PackTags(flag.Tags)).Scan(&id)
	if err != nil {
		return -1, err
	}
	return id, nil
}
CreateFlag adds a new flag to the database
package database
import (
	"database/sql"
	"github.com/nsec/askgod/api"
	"github.com/nsec/askgod/internal/utils"
)
func (db *DB) GetFlags() ([]api.AdminFlag, error) {
	resp := []api.AdminFlag{}
	rows, err := db.Query("SELECT id, flag, value, return_string, description, tags FROM flag ORDER BY id ASC;")
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	for rows.Next() {
		row := api.AdminFlag{}
		tags := ""
		err := rows.Scan(&row.ID, &row.Flag, &row.Value, &row.ReturnString, &row.Description, &tags)
		if err != nil {
			return nil, err
		}
		row.Tags, err = utils.ParseTags(tags)
		if err != nil {
			return nil, err
		}
		resp = append(resp, row)
	}
	err = rows.Err()
	if err != nil {
		return nil, err
	}
	return resp, nil
}
func (db *DB) GetFlag(id int64) (*api.AdminFlag, error) {
	row := api.AdminFlag{}
	tags := ""
	err := db.QueryRow("SELECT id, flag, value, return_string, description, tags FROM flag WHERE id=$1;", id).Scan(
		&row.ID, &row.Flag, &row.Value, &row.ReturnString, &row.Description, &tags)
	if err != nil {
		return nil, err
	}
	row.Tags, err = utils.ParseTags(tags)
	if err != nil {
		return nil, err
	}
	return &row, nil
}