Documentation
¶
Overview ¶
Package memory provides an in-memory implementation of adapter.Adapter.
It executes schema-driven generic CRUD operations with indexing and unique constraint checking in memory. It is ideal for unit tests, local development, and CI environments.
Index ¶
- type Adapter
- func (a *Adapter) Count(ctx context.Context, model string, where []adapter.Condition) (int64, error)
- func (a *Adapter) Create(ctx context.Context, model string, data map[string]any) (map[string]any, error)
- func (a *Adapter) Delete(ctx context.Context, model string, where []adapter.Condition) (int64, error)
- func (a *Adapter) FindMany(ctx context.Context, q adapter.Query) ([]map[string]any, error)
- func (a *Adapter) FindOne(ctx context.Context, model string, where []adapter.Condition) (map[string]any, error)
- func (a *Adapter) RegisterSchema(ctx context.Context, s *schema.Schema) error
- func (a *Adapter) Transaction(ctx context.Context, fn func(ctx context.Context, tx adapter.Adapter) error) error
- func (a *Adapter) Update(ctx context.Context, model string, where []adapter.Condition, ...) (int64, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Adapter ¶
type Adapter struct {
// contains filtered or unexported fields
}
Adapter is an in-memory adapter.Adapter implementation.
func (*Adapter) Count ¶
func (a *Adapter) Count(ctx context.Context, model string, where []adapter.Condition) (int64, error)
Count returns the number of records matching the conditions.
func (*Adapter) Create ¶
func (a *Adapter) Create(ctx context.Context, model string, data map[string]any) (map[string]any, error)
Create inserts a record into the specified model.
func (*Adapter) Delete ¶
func (a *Adapter) Delete(ctx context.Context, model string, where []adapter.Condition) (int64, error)
Delete removes matching records.
func (*Adapter) FindMany ¶
FindMany returns all records matching query conditions, supporting sorting and pagination.
func (*Adapter) FindOne ¶
func (a *Adapter) FindOne(ctx context.Context, model string, where []adapter.Condition) (map[string]any, error)
FindOne returns the first record matching all given conditions.
func (*Adapter) RegisterSchema ¶
RegisterSchema registers the compiled schema into the in-memory adapter.