func (conf *Settings) NewJSON(service, name, value string) error {
	entry := conf.EmptyValue(service, name, TypeString)
	entry.JSON = true
	entry.String = value
	if conf.DB.NewRecord(entry) {
		if err := conf.DB.Create(&entry).Error; err != nil {
			return fmt.Errorf("Create NewJSON %v", err)
		}
	} else {
		return fmt.Errorf("db.NewRecord did not return true")
	}
	return nil
}
NewJSON creates a new JSON value
package settings
import (
	"fmt"
	"log"
	"github.com/jinzhu/gorm"
)
const (
	ServiceTLS   string = "tls"
	ServiceAdmin string = "admin"
	ServiceAPI   string = "api"
)
const (
	TypeString  string = "string"
	TypeBoolean string = "boolean"
	TypeInteger string = "integer"
)
const (
	AuthNone    string = "none"
	AuthJSON    string = "json"
	AuthDB      string = "db"
	AuthSAML    string = "saml"
	AuthHeaders string = "headers"
	AuthJWT     string = "jwt"
)
const (
	LoggingNone    string = "none"
	LoggingStdout  string = "stdout"
	LoggingDB      string = "db"
	LoggingGraylog string = "graylog"
	LoggingSplunk  string = "splunk"
	LoggingELK     string = "elk"
	LoggingKafka   string = "kafka"
)
const (
	DebugHTTP          string = "debug_http"
	DebugService       string = "debug_service"
	RefreshEnvs        string = "refresh_envs"
	RefreshSettings    string = "refresh_settings"
	CleanupSessions    string = "cleanup_sessions"
	ServiceMetrics     string = "service_metrics"
	MetricsHost        string = "metrics_host"
	MetricsPort        string = "metrics_port"
	MetricsProtocol    string = "metrics_protocol"
	DefaultEnv         string = "default_env"
	InactiveHours      string = "inactive_hours"
	AcceleratedSeconds string = "accelerated_seconds"
	NodeDashboard      string = "node_dashboard"
)
const (
	QueryResultLink     string = "query_result_link"
	StatusLogsLink      string = "status_logs_link"
	ResultLogsLink      string = "result_logs_link"
	CleanStatusLogs     string = "clean_status_logs"
	CleanStatusInterval string = "clean_status_interval"
	CleanResultLogs     string = "clean_result_logs"
	CleanResultInterval string = "clean_result_interval"
	CleanQueryLogs      string = "clean_query_logs"
	CleanQueryEntries   string = "clean_query_entries"
)
const (
	QueryLink   string = "/query/logs/{{NAME}}"
	StatusLink  string = "#status-logs"
	ResultsLink string = "#result-logs"
)
const (
	JSONListener string = "json_listener"
	JSONPort     string = "json_port"
	JSONHost     string = "json_host"
	JSONAuth     string = "json_auth"
	JSONLogging  string = "json_logging"
)
type SettingValue struct {
	gorm.Model
	Name    string `gorm:"index"`
	Service string
	JSON    bool
	Type    string
	String  string
	Boolean bool
	Integer int64
	Info    string
}
type MapSettings map[string]SettingValue
type Settings struct {
	DB *gorm.DB
}
var ValidTypes = map[string]struct{}{
	TypeString:  struct{}{},
	TypeBoolean: struct{}{},
	TypeInteger: struct{}{},
}
func NewSettings(backend *gorm.DB) *Settings {
	var s *Settings
	s = &Settings{DB: backend}
	if err := backend.AutoMigrate(SettingValue{}).Error; err != nil {
		log.Fatalf("Failed to AutoMigrate table (setting_values): %v", err)
	}
	return s
}
func (conf *Settings) EmptyValue(service, name, typeValue string) SettingValue {
	return SettingValue{
		Name:    name,
		Service: service,
		JSON:    false,
		Type:    typeValue,
		String:  "",
		Integer: int64(0),
		Boolean: false,
		Info:    "",
	}
}
func (conf *Settings) NewValue(service, name, typeValue string, value interface{}) error {
	entry := conf.EmptyValue(service, name, typeValue)
	switch typeValue {
	case TypeBoolean:
		entry.Boolean = value.(bool)
	case TypeInteger:
		entry.Integer = value.(int64)
	case TypeString:
		entry.String = value.(string)
	}
	if conf.DB.NewRecord(entry) {
		if err := conf.DB.Create(&entry).Error; err != nil {
			return fmt.Errorf("Create NewValue %v", err)
		}
	} else {
		return fmt.Errorf("db.NewRecord did not return true")
	}
	return nil
}