Improved documentation

This commit is contained in:
Eduard Urbach 2023-07-06 14:34:22 +02:00
parent 35c039d01b
commit 3949809138
Signed by: akyoto
GPG Key ID: C874F672B1AF20C0

View File

@ -4,11 +4,17 @@ In-memory key value store that saves your data to plain old JSON files.
If you like, you can operate on your entire data with classic UNIX tools. If you like, you can operate on your entire data with classic UNIX tools.
Let's say we use this struct to save our user data:
```go ```go
type User struct { type User struct {
Name string Name string
} }
```
Then we can create a typesafe collection using Go generics:
```go
// Data saved to ~/.ocean/User/ // Data saved to ~/.ocean/User/
users := ocean.New[User]("User") users := ocean.New[User]("User")
@ -16,11 +22,11 @@ users := ocean.New[User]("User")
users.Set("1", &User{Name: "User 1"}) users.Set("1", &User{Name: "User 1"})
``` ```
In a real project you would usually prefix your user collection with a project or company name, serving as a namespace: In a real project you would usually prefix your collections with a project or company name:
```go ```go
// Data saved to ~/.ocean/google/User/ // Data saved to ~/.ocean/google/User/
users := ocean.New("google", "User") users := ocean.New[User]("google", "User")
``` ```
You can add as many hierarchies as you need but I recommend using a simple `/namespace/collection/` structure. You can add as many hierarchies as you need but I recommend using a simple `/namespace/collection/` structure.