restructuring of files. added 2 new methods(Asc, Desc) to field

This commit is contained in:
2025-10-18 12:31:46 +05:30
parent 6f5748d3d3
commit 325103e8ef
13 changed files with 433 additions and 446 deletions

View File

@@ -12,29 +12,33 @@ import (
"github.com/jackc/pgx/v5"
)
type insertQry struct {
returing *string
onConflict *string
table string
conflictAction string
fields []string
vals []string
args []any
debug bool
}
func (t *Table) Insert() Insert {
qb := &insertQry{
table: t.Name,
fields: make([]string, 0, t.FieldCount),
vals: make([]string, 0, t.FieldCount),
args: make([]any, 0, t.FieldCount),
debug: t.debug,
type (
InsertClause interface {
Insert
Returning(field Field) First
OnConflict(fields ...Field) Do
Execute
Stringer
}
return qb
}
Insert interface {
Set(field Field, val any) InsertClause
SetMap(fields map[Field]any) InsertClause
}
insertQry struct {
returing *string
onConflict *string
table string
conflictAction string
fields []string
vals []string
args []any
debug bool
}
)
func (q *insertQry) Set(field Field, val any) InsertClause {
q.fields = append(q.fields, field.Name())