nidus-sync/db/query/public/site.go
Eli Ribble fcd95f1a25
Get back to compiling, but using new jet for publicreport
This was an epically long change, and a terrible idea, but it compiles.
This was essentially a cascade that came about because I can't blend jet
and bob in the same transaction. In for a penny, I guess...
2026-05-07 10:39:17 +00:00

38 lines
1.2 KiB
Go

package public
import (
"context"
"errors"
"fmt"
//"time"
//"github.com/Gleipnir-Technology/bob"
"github.com/Gleipnir-Technology/nidus-sync/db"
"github.com/Gleipnir-Technology/nidus-sync/db/gen/nidus-sync/public/model"
"github.com/Gleipnir-Technology/nidus-sync/db/gen/nidus-sync/public/table"
"github.com/go-jet/jet/v2/postgres"
)
func SiteFromAddressIDForOrg(ctx context.Context, txn db.Ex, address_id int64, org_id int64) (*model.Site, error) {
statement := table.Site.SELECT(
table.Site.AllColumns,
).FROM(table.Site).
WHERE(table.Site.AddressID.EQ(postgres.Int(address_id)).AND(
table.Site.OrganizationID.EQ(postgres.Int(org_id))))
result, err := db.ExecuteOneTx[model.Site](ctx, txn, statement)
if err != nil {
if errors.Is(err, db.ErrNoRows) {
return nil, nil
}
return nil, fmt.Errorf("query: %w", err)
}
return &result, nil
}
func SiteFromIDForOrg(ctx context.Context, comm_id int64, org_id int64) (model.Site, error) {
statement := table.Site.SELECT(
table.Site.AllColumns,
).FROM(table.Site).
WHERE(table.Site.ID.EQ(postgres.Int(comm_id)).AND(
table.Site.OrganizationID.EQ(postgres.Int(org_id))))
return db.ExecuteOne[model.Site](ctx, statement)
}