From cca489e399fc816a6dbb73584c61770e8d16ec30 Mon Sep 17 00:00:00 2001 From: Matthew R Kasun Date: Thu, 8 Feb 2024 13:52:59 -0500 Subject: [PATCH] insert/update functions --- README.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 24cbb52..5e00666 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,9 @@ defer boltd.Close() ```` ### Create/Update pass the key/value pair along with table name +#### Save -- save key/value always (overwrite existing or create new) +#### Insert -- save only iff key does not exist +#### Update -- save only iff key exists ```` cont userTable = "users" @@ -44,14 +47,14 @@ if err := boltdb.Save(user, user.Username, userTable); err != nil { ### Read return value of key in table ```` -user, err := boltdb.Read(models.User{}, "admin", userTable) +user, err := boltdb.Get(models.User{}, "admin", userTable) if err != nil { return err } ```` retrieve all values from table ```` -users, err := boltdb.ReadAll(models.User{}, userTable) +users, err := boltdb.GetAll(models.User{}, userTable) if err != nil { return err } @@ -101,6 +104,5 @@ func AdminExists() bool { } return found } - return found -} + ````