Documentation ¶
Index ¶
- func MakeUpsertQuery(qc QueryConfig, returnPK bool) string
- func RefreshHMSViews(db *sqlx.DB) echo.HandlerFunc
- func UpsertHMSModel(ac *config.APIConfig) echo.HandlerFunc
- func UpsertToDB(definitionFile string, ac *config.APIConfig) (err error)
- func VacuumHMSViews(db *sqlx.DB) echo.HandlerFunc
- type QueryConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MakeUpsertQuery ¶
func MakeUpsertQuery(qc QueryConfig, returnPK bool) string
MakeUpsertQuery builds the upsert query using the QueryConfig struct. The following is an example of the upsert query used for writing data to the models table: 'INSERT INTO models.hms (name, data_group, type, collection_id, s3_key, model_metadata, etl_metadata) VALUES ($1, $2, $3, $4, $5, $6, $7) ON CONFLICT (s3_key) DO UPDATE SET name = $1, data_group = $2, type = $3, collection_id = $4, s3_key = $5, model_metadata = $6, etl_metadata = $7;'
func UpsertToDB ¶
Upsert extracts metadata from a HEC-HMS model and writes this data to a database using upsert statements. These upsert statements insert a row where it does not exist, or updates the row with new values when it does. A database transaction is used so that in the case of an error, no model data is written to the database, i.e. the transation is aborted, which prevents incomplete tables for a given model. Furthermore, tx.Get is used so that the primary key from one table is returned and can be used as a foreign key in subsequent tables.
Types ¶
type QueryConfig ¶
type QueryConfig struct {
// contains filtered or unexported fields
}
QueryConfig ...