Skip to content

Commit

Permalink
insert/update functions
Browse files Browse the repository at this point in the history
  • Loading branch information
mattkasun authored Feb 8, 2024
1 parent 4b64d28 commit cca489e
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
}
Expand Down Expand Up @@ -101,6 +104,5 @@ func AdminExists() bool {
}
return found
}
return found
}
````

0 comments on commit cca489e

Please sign in to comment.