Browse Source

Update README.md

Volodymyr Tkach 2 years ago
parent
commit
b5bd5b5d85
1 changed files with 12 additions and 0 deletions
  1. 12 0
      README.md

+ 12 - 0
README.md

@@ -39,6 +39,8 @@ InsertRow(ctx context.Context, row any) error
 PrepareSQL(query string, args ...any) *common.Prepared
 QueryRowByID(ctx context.Context, id int64, row any) error
 RowExists(ctx context.Context, id int64, row any) bool
+UpdateRow(ctx context.Context, row any) error
+UpdateRowOnly(ctx context.Context, row any, only ...string) error
 ```
 
 Please mark structure fields for using this funcs:
@@ -58,6 +60,16 @@ rowUser.Name = "John"
 if err := db.InsertRow(context.Background(), &rowUser); err != nil {
     fmt.Printf("%s\n", err.Error())
 }
+
+rowUser.ID = 1
+rowUser.Name = "Alice"
+if err := db.UpdateRow(context.Background(), &rowUser); err != nil {
+    fmt.Printf("%s\n", err.Error())
+}
+
+if err := db.UpdateRowOnly(context.Background(), &rowUser, "name"); err != nil {
+    fmt.Printf("%s\n", err.Error())
+}
 ```
 
 ## Examples