From 394980913884603809f6581f38e2ce2d362256a8 Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Thu, 6 Jul 2023 14:34:22 +0200 Subject: [PATCH] Improved documentation --- README.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index df2db15..2f4f67b 100644 --- a/README.md +++ b/README.md @@ -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. +Let's say we use this struct to save our user data: + ```go type User struct { Name string } +``` +Then we can create a typesafe collection using Go generics: + +```go // Data saved to ~/.ocean/User/ users := ocean.New[User]("User") @@ -16,11 +22,11 @@ users := ocean.New[User]("User") 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 // 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.