2026-05-01 17:28:33 +00:00
|
|
|
package arcgis
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
|
|
|
|
|
"github.com/Gleipnir-Technology/bob"
|
2026-05-09 01:48:56 +00:00
|
|
|
"github.com/Gleipnir-Technology/jet/postgres"
|
2026-05-01 17:28:33 +00:00
|
|
|
"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"
|
|
|
|
|
)
|
|
|
|
|
|
2026-05-07 10:39:17 +00:00
|
|
|
func ServiceMapFromID(ctx context.Context, id string) (model.ServiceMap, error) {
|
2026-05-01 17:28:33 +00:00
|
|
|
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)
|
|
|
|
|
}
|
2026-05-07 10:39:17 +00:00
|
|
|
func ServiceMapsFromAccountID(ctx context.Context, account_id string) ([]model.ServiceMap, error) {
|
2026-05-01 17:28:33 +00:00
|
|
|
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).
|
2026-05-07 16:38:42 +00:00
|
|
|
MODEL(m).
|
|
|
|
|
RETURNING(table.ServiceMap.AllColumns)
|
2026-05-04 20:57:50 +00:00
|
|
|
return db.ExecuteNoneTxBob(ctx, txn, statement)
|
2026-05-01 17:28:33 +00:00
|
|
|
}
|