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

59
pgm_table.go Normal file
View File

@@ -0,0 +1,59 @@
package pgm
// Table in database
type Table struct {
Name string
PK []string
FieldCount uint16
debug bool
}
// Debug when set true will print generated query string in stdout
func (t *Table) Debug() Clause {
t.debug = true
return t
}
// Insert table statement
func (t *Table) Insert() InsertClause {
qb := &insertQry{
debug: t.debug,
table: t.Name,
fields: make([]string, 0, t.FieldCount),
vals: make([]string, 0, t.FieldCount),
args: make([]any, 0, t.FieldCount),
}
return qb
}
// Select table statement
func (t *Table) Select(field ...Field) SelectClause {
qb := &selectQry{
debug: t.debug,
table: t.Name,
fields: field,
}
return qb
}
// Update table statement
func (t *Table) Update() UpdateClause {
qb := &updateQry{
debug: t.debug,
table: t.Name,
cols: make([]string, 0, t.FieldCount),
args: make([]any, 0, t.FieldCount),
}
return qb
}
// Detlete table statement
func (t *Table) Delete() DeleteCluase {
qb := &deleteQry{
debug: t.debug,
table: t.Name,
}
return qb
}