Skip to content

Commit 6435e2d

Browse files
committed
feat: new commands
1 parent 827d104 commit 6435e2d

File tree

2 files changed

+9
-16
lines changed

2 files changed

+9
-16
lines changed

README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ This function will diconnect from chrono db
2222

2323
3. CreateStream <<**CHRONO_NAME** *string* :: **STREAM_NAME** *string*>>
2424

25-
4. WriteEvent <<**CHRONO_NAME** *string* :: **STREAM_NAME** *string* :: **EVENTS** { **HEADER**, **BODY** *(string, string)* } >>
25+
4. WriteEvent
26+
27+
<<**CHRONO_NAME** *string* :: **STREAM_NAME** *string* :: **EVENTS** { **HEADER**, **BODY** *(string, string)* } >>
2628

2729
5. Read <<**CHRONO_NAME** *string* :: **STREAM_NAME** *string*>>
2830

client/client.go

+6-15
Original file line numberDiff line numberDiff line change
@@ -21,37 +21,28 @@ func (c *Client) Close() error {
2121
return c.conn.Close()
2222
}
2323

24-
func (c *Client) CreateChrono(chrono string) error {
25-
if response, err := c.conn.Execute("cc " + "heheh"); err != nil || response != "OK" {
26-
return fmt.Errorf("create failed: %v", err)
27-
}
28-
return nil
29-
}
30-
3124
func (c *Client) CreateStream(chrono string, stream string) error {
32-
if response, err := c.conn.Execute("cs " + stream); err != nil || response != "OK" {
25+
if response, err := c.conn.Execute("CREATE STREAM " + stream); err != nil || response != "OK" {
3326
return fmt.Errorf("create failed: %v", err)
3427
}
3528
return nil
3629
}
3730
func (c *Client) DeleteStream(chrono string, stream string) error {
38-
if response, err := c.conn.Execute("ds " + stream); err != nil || response != "OK" {
31+
if response, err := c.conn.Execute("DELETE STREAM " + stream); err != nil || response != "OK" {
3932
return fmt.Errorf("delete failed: %v", err)
4033
}
4134
return nil
4235
}
4336

44-
func (c *Client) WriteEvent(chrono string, stream string, data map[string]string) error {
45-
command := "w " + stream + " "
46-
for k, v := range data {
47-
command += k + " " + v + " "
48-
}
37+
func (c *Client) WriteEvent(chrono string, stream string, event string) error {
38+
command := "INSERT " + event + " INTO " + stream
39+
fmt.Println(command+"this is cm")
4940
if response, err := c.conn.Execute(command); err != nil || response != "OK" {
5041
return fmt.Errorf("write failed: %v", err)
5142
}
5243
return nil
5344
}
5445

5546
func (c *Client) Read(chrono string, stream string) (string, error) {
56-
return c.conn.Execute("r " + stream)
47+
return c.conn.Execute("SELECT * FROM " + stream)
5748
}

0 commit comments

Comments
 (0)