Quick Start
This guide gets you started with scio in 5 minutes.
Installation
go get github.com/zoobz-io/scio
Basic Usage
1. Create a scio Instance
import "github.com/zoobz-io/scio"
s := scio.New()
2. Register Resources
Register your grub providers with scio using URIs:
// Assuming you have grub resources
usersDB, _ := grub.NewDatabase[User](db, "users", "id", renderer)
sessionsStore := grub.NewStore[Session](redisProvider)
// Register with scio
s.RegisterDatabase("db://users", usersDB.Atomic())
s.RegisterStore("kv://sessions", sessionsStore.Atomic())
3. Perform Operations
Access data via URIs:
ctx := context.Background()
// Get a record
atom, err := s.Get(ctx, "db://users/123")
if err != nil {
// Handle error
}
// Access fields
email := atom.Strings["email"]
age := atom.Ints["age"]
// Set a record
s.Set(ctx, "kv://sessions/abc", sessionAtom)
// Check existence
exists, _ := s.Exists(ctx, "db://users/123")
// Delete
s.Delete(ctx, "db://users/123")
4. Query Databases
For database resources, use query operations:
// Query all records
results, _ := s.Query(ctx, "db://users", grub.QueryAll, nil)
// Query with parameters
stmt := edamame.NewQueryStatement(...)
results, _ := s.Query(ctx, "db://users", stmt, map[string]any{
"status": "active",
})
5. Introspect the Topology
Discover what resources exist:
// All resources
for _, r := range s.Sources() {
fmt.Printf("%s (%s)\n", r.URI, r.Variant)
}
// Find resources by spec
related := s.FindBySpec(userSpec)
// Find resources by field
withEmail := s.FindByField("email")
Next Steps
- Core Concepts — Understand URIs, specs, and the catalog
- Architecture — How scio fits in your system