From 8283dba8fed617cad3ac735160512440cb647a71 Mon Sep 17 00:00:00 2001 From: Elliot Chen <92676541+elliotchenzichang@users.noreply.github.com> Date: Sat, 17 Aug 2024 02:27:23 +0800 Subject: [PATCH] add basic operation of rows --- database/row.go | 19 +++++++++++++++++-- database/table.go | 16 ++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/database/row.go b/database/row.go index 284afbf..214e554 100644 --- a/database/row.go +++ b/database/row.go @@ -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 } diff --git a/database/table.go b/database/table.go index cf94536..7047dc9 100644 --- a/database/table.go +++ b/database/table.go @@ -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 }