Skip to content

Commit 5d0d021

Browse files
pararangMuhammad Ikhsanactions-user
authored
doc: update API (#14)
* doc: update API * chore: Updated coverage badge. Co-authored-by: Muhammad Ikhsan <muhammad.ikhsan@efishery.com> Co-authored-by: GitHub Action <action@github.com>
1 parent 1e908d8 commit 5d0d021

File tree

1 file changed

+36
-2
lines changed

1 file changed

+36
-2
lines changed

README.md

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ resp, err = steinClient.Add("sheet1",
5353
"column_1": "value_1",
5454
"column_2": "value_2",
5555
})
56-
// handle err adn do something with resp
56+
// handle err and do something with resp
5757
...
5858
```
5959

@@ -79,11 +79,45 @@ resp, err = steinClient.Add("sheet1", rows...)
7979
// handle err then do something with resp
8080
...
8181
```
82+
### Update
83+
#### Update single row
84+
`Limit 1` indicate to update only the first row that match the `Condition`.
85+
```go
86+
...
87+
resp, err := sc.Update("Sheet1", UpdateParams{
88+
Condition: map[string]string{
89+
"column_1": "if_has_this_value",
90+
},
91+
Set: map[string]string{
92+
"column_2": "then_update_this_colum_value",
93+
},
94+
Limit: 1,
95+
})
96+
// handle err and do something with resp
97+
...
98+
```
99+
#### Update with multiple condition
100+
All `Condition` will be translated to `AND` condition.
101+
```go
102+
...
103+
resp, err := sc.Update("Sheet1", UpdateParams{
104+
Condition: map[string]string{
105+
"column_1": "if_has_this_value",
106+
"column_3": "and_if_has_this_value",
107+
},
108+
Set: map[string]string{
109+
"column_2": "then_update_this_colum_value",
110+
},
111+
})
112+
// handle err and do something with resp
113+
...
114+
```
115+
> :warning: **If `Limit` is not set, all rows those match the `Condition` will be updated.**
82116
83117
## TODO
84118
- [x] Read data (https://docs.steinhq.com/read-data)
85119
- [x] Read data with conditions (https://docs.steinhq.com/search-data)
86120
- [x] Add data (https://docs.steinhq.com/add-rows)
87-
- [ ] Update data (https://docs.steinhq.com/update-rows)
121+
- [x] Update data (https://docs.steinhq.com/update-rows)
88122
- [ ] Delete data (https://docs.steinhq.com/delete-rows)
89123
- [ ] Authentication (https://docs.steinhq.com/authentication)

0 commit comments

Comments
 (0)