package arcgis

import (
	"context"

	"github.com/Gleipnir-Technology/bob"
	"github.com/Gleipnir-Technology/jet/postgres"
	"source.gleipnir.technology/Gleipnir/nidus-sync/db"
	"source.gleipnir.technology/Gleipnir/nidus-sync/db/gen/nidus-sync/arcgis/model"
	"source.gleipnir.technology/Gleipnir/nidus-sync/db/gen/nidus-sync/arcgis/table"
)

func AccountFromID(ctx context.Context, org_id string) (model.Account, error) {
	statement := table.Account.SELECT(
		table.Account.AllColumns,
	).FROM(table.Account).
		WHERE(table.Account.ID.EQ(postgres.String(org_id)))
	return db.ExecuteOne[model.Account](ctx, statement)
}
func AccountInsert(ctx context.Context, txn bob.Tx, m *model.Account) (model.Account, error) {
	statement := table.Account.INSERT(table.Account.MutableColumns).
		MODEL(m).
		RETURNING(table.Account.AllColumns)
	return db.ExecuteOneTxBob[model.Account](ctx, txn, statement)
}
