nidus-sync/db/query/arcgis/service_map.go
Eli Ribble 935800e334
Switch to using the Gleipnir fork of jet
Because we need those sweet, sweet geometry columns
2026-05-09 01:48:56 +00:00

32 lines
1.2 KiB
Go

package arcgis
import (
"context"
"github.com/Gleipnir-Technology/bob"
"github.com/Gleipnir-Technology/jet/postgres"
"github.com/Gleipnir-Technology/nidus-sync/db"
"github.com/Gleipnir-Technology/nidus-sync/db/gen/nidus-sync/arcgis/model"
"github.com/Gleipnir-Technology/nidus-sync/db/gen/nidus-sync/arcgis/table"
)
func ServiceMapFromID(ctx context.Context, id string) (model.ServiceMap, error) {
statement := table.ServiceMap.SELECT(
table.ServiceMap.AllColumns,
).FROM(table.ServiceMap).
WHERE(table.ServiceMap.ArcgisID.EQ(postgres.String(id)))
return db.ExecuteOne[model.ServiceMap](ctx, statement)
}
func ServiceMapsFromAccountID(ctx context.Context, account_id string) ([]model.ServiceMap, error) {
statement := table.ServiceMap.SELECT(
table.ServiceMap.AllColumns,
).FROM(table.ServiceMap).
WHERE(table.ServiceMap.AccountID.EQ(postgres.String(account_id)))
return db.ExecuteMany[model.ServiceMap](ctx, statement)
}
func ServiceMapInsert(ctx context.Context, txn bob.Tx, m *model.ServiceMap) error {
statement := table.ServiceMap.INSERT(table.ServiceMap.MutableColumns).
MODEL(m).
RETURNING(table.ServiceMap.AllColumns)
return db.ExecuteNoneTxBob(ctx, txn, statement)
}