Documentation
¶
Index ¶
- type Collection
- func (c *Collection) Clear() error
- func (c *Collection) Count() (int, error)
- func (c *Collection) Delete(id string) error
- func (c *Collection) Get(id string) (map[string]any, error)
- func (c *Collection) Insert(doc map[string]any) (string, error)
- func (c *Collection) List() ([]map[string]any, error)
- func (c *Collection) Seed(path string) error
- func (c *Collection) Update(id string, doc map[string]any) error
- type Store
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Collection ¶
type Collection struct {
// contains filtered or unexported fields
}
Collection is a simple document store backed by a SQLite table. Each document is a JSON object stored as TEXT in a single "data" column.
func (*Collection) Clear ¶ added in v0.2.0
func (c *Collection) Clear() error
Clear removes every document from the collection (keeps the table). Used by reset.
func (*Collection) Count ¶
func (c *Collection) Count() (int, error)
Count returns the number of documents in the collection.
func (*Collection) Delete ¶
func (c *Collection) Delete(id string) error
Delete removes the document at id. No-op (nil error) if it doesn't exist.
func (*Collection) Get ¶
func (c *Collection) Get(id string) (map[string]any, error)
Get retrieves a single document by id. Returns sql.ErrNoRows when the document does not exist.
func (*Collection) Insert ¶
func (c *Collection) Insert(doc map[string]any) (string, error)
Insert adds doc to the collection. If doc has an "id" key it is used; otherwise a random hex id is generated. The id is stamped into the stored document (on a copy) and returned. The caller's map is never mutated (M1).
func (*Collection) List ¶
func (c *Collection) List() ([]map[string]any, error)
List returns all documents in the collection.
func (*Collection) Seed ¶
func (c *Collection) Seed(path string) error
Seed reads a JSONL file (one JSON object per line) and inserts each object. It only seeds when the collection is empty, making restarts idempotent and avoiding duplicate seed rows or UNIQUE-constraint failures (C3).
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store wraps a *sql.DB for collection-based document storage.
func (*Store) Collection ¶
func (s *Store) Collection(name string) (*Collection, error)
Collection returns a Collection backed by table <name>, creating it if needed. The name must match ^[A-Za-z_][A-Za-z0-9_]*$ to prevent SQL injection (C2).
func (*Store) CollectionNames ¶ added in v0.2.0
CollectionNames returns the names of all collection tables currently in the store (each collection is its own table). Used by the dashboard's data browser. System/internal tables (sqlite_*) are excluded.
func (*Store) DropCollection ¶ added in v0.2.0
DropCollection removes a collection table. No-op (nil error) if it doesn't exist. Used by reset.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package blob provides a filesystem-backed file-content store for services like Drive/Dropbox/S3.
|
Package blob provides a filesystem-backed file-content store for services like Drive/Dropbox/S3. |
|
Package clock provides a deterministic virtual clock for tests and a real-time clock for normal runs.
|
Package clock provides a deterministic virtual clock for tests and a real-time clock for normal runs. |
|
Package events provides a webhook emitter for pushing event payloads to registered target URLs via HTTP POST.
|
Package events provides a webhook emitter for pushing event payloads to registered target URLs via HTTP POST. |
|
Package gen provides a named generator registry.
|
Package gen provides a named generator registry. |
|
Package identity provides a local "yes" auth issuer that mints and validates opaque HMAC-SHA256 tokens with simulated scopes.
|
Package identity provides a local "yes" auth issuer that mints and validates opaque HMAC-SHA256 tokens with simulated scopes. |
|
Package validator validates a Go value (a parsed JSON map or any other JSON-compatible type) against a JSON-Schema document.
|
Package validator validates a Go value (a parsed JSON map or any other JSON-compatible type) against a JSON-Schema document. |