restructuring of files. added 2 new methods(Asc, Desc) to field
This commit is contained in:
59
pgm_table.go
Normal file
59
pgm_table.go
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user