Documentation ¶
Index ¶
Constants ¶
const ( PostgresDriver = "postgres" OracleDriver = "oci8" MySQLDriver = "mysql" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type JsonStringSlice ¶
type JsonStringSlice []string
Represents a string list stored in the DB in JSON format.
func (*JsonStringSlice) Scan ¶
func (l *JsonStringSlice) Scan(src interface{}) error
type JsonbMap ¶
type JsonbMap map[string]interface{}
Automatically converts JSON type from DB into a map[string]interface{}
type Model ¶
var DB *Model
func InitDB ¶
Connects to the DB based on the driver set in the env variable "DB_DRIVER" Currently supported values for DB_DRIVER = "postgres" for postgres, "oci8" for oracle
func InitMySQLDB ¶
func InitOracleDB ¶
func InitPostgresDB ¶
type ORM ¶
type ORM struct { ID Primary `gorm:"primary_key"` CreatedAt time.Time UpdatedAt time.Time DeletedAt *time.Time `sql:"index"` }
Mimicks gorm.Model except ID is of type Primary
type ORMJson ¶
type ORMJson struct {
json.RawMessage
}
Use in migrations in case the DB entry is to be made in JSON format Can use JsonbMap or JsonStringSlice to automatically unmarshal from db into the desired data type in the actual code Currently, all the supported dialects (postgres, oracle, mysql) are written so that ORMJson is assumed to be a json type. If this code is changed, we can use JsonbMap as well.
func CreateORMJson ¶
func CreateORMJson(i interface{}) ORMJson
Creates a postgres JSON from an interface