package public

import (
	"context"

	"github.com/Gleipnir-Technology/jet/postgres"
	"source.gleipnir.technology/Gleipnir/nidus-sync/db"
	"source.gleipnir.technology/Gleipnir/nidus-sync/db/gen/nidus-sync/public/model"
	"source.gleipnir.technology/Gleipnir/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)
}
*/
