Skip to content

Commit

Permalink
add basic operation of rows
Browse files Browse the repository at this point in the history
  • Loading branch information
elliotchenzichang committed Aug 16, 2024
1 parent dd5ca73 commit 8283dba
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
19 changes: 17 additions & 2 deletions database/row.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,24 @@ type Rows []Row
// Row defines the real data in database,
// and the data should be fited to the table schema definition
type Row struct {
table string
data map[string]interface{}
}

func NewRow(tableName string) *Row {
return &Row{table: tableName}
return &Row{
data: map[string]interface{}{},
}
}

func (r *Row) AddField(name string, value interface{}) *Row {
r.data[name] = value
return r
}

func (r *Row) Submit() map[string]interface{} {
return r.data
}

func (r *Row) Validate() error {
return nil
}
16 changes: 16 additions & 0 deletions database/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,22 @@ func (t *Table) Clean() error {
return nil
}

func (t *Table) AddRow(r *Row) {

}

func (t *Table) UpdateRow() {

}

func (t *Table) DeleteRow() {

}

func (t *Table) AddRows(rs Rows) {

}

type TableBuilder struct {
table *Table
}
Expand Down

0 comments on commit 8283dba

Please sign in to comment.