package publicreport

import (
	"context"
	//"time"

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

func WaterInsert(ctx context.Context, txn db.Ex, m model.Water) (model.Water, error) {
	statement := table.Water.INSERT(table.Water.AllColumns).
		MODEL(m).
		RETURNING(table.Water.AllColumns)
	return db.ExecuteOneTx[model.Water](ctx, txn, statement)
}
func WaterFromReportID(ctx context.Context, txn db.Ex, report_id int64) (model.Water, error) {
	statement := table.Water.SELECT(table.Water.AllColumns).
		FROM(table.Water).
		WHERE(table.Water.ReportID.EQ(postgres.Int(report_id)))
	return db.ExecuteOneTx[model.Water](ctx, txn, statement)
}
