nidus-sync/db/query/public/organization.go
Eli Ribble f1fe8b4d2b
Add contacts, rework comms schema
This in a pretty huge change. At a high level we're adding the concept
of a 'contact' which is a person or organization that has zero or more
contact methods (email, phone). This ended up cascading a number of
changes, including critically to the publicreprt schema. In the end it
seemed safer to get to the point where I'm confident we aren't using any
of the old fields for storing reporter information (though I haven't
deleted the columns yet) so I removed the code for defining those
columns.

At this point I think it's not possible for me to regenerate the bob
schema due to the interdependencies between my various schemas, so the
migration is well-and-truly happening.
2026-05-15 16:58:28 +00:00

36 lines
1.3 KiB
Go

package public
import (
"context"
"github.com/Gleipnir-Technology/jet/postgres"
"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"
)
func OrganizationInsert(ctx context.Context, txn db.Ex, m model.Organization) (model.Organization, error) {
statement := table.Organization.INSERT(table.Organization.MutableColumns).
MODEL(m).
RETURNING(table.Organization.AllColumns)
return db.ExecuteOneTx[model.Organization](ctx, txn, statement)
}
func OrganizationFromID(ctx context.Context, txn db.Ex, org_id int64) (model.Organization, error) {
statement := table.Organization.SELECT(
table.Organization.AllColumns,
).FROM(table.Organization).
WHERE(table.Organization.ID.EQ(postgres.Int(org_id)))
return db.ExecuteOne[model.Organization](ctx, statement)
}
/*
func OrganizationSetStatus(ctx context.Context, txn db.Tx, org_id int64, org_id int64, status model.Organizationstatus) error {
statement := table.Organization.UPDATE().
SET(
table.Organization.Status.SET(postgres.NewEnumValue(status.String())),
).
WHERE(table.Organization.OrganizationID.EQ(postgres.Int(org_id)).AND(
table.Organization.ID.EQ(postgres.Int(org_id))))
return db.ExecuteNoneTx(ctx, txn, statement)
}
*/