Documentation
¶
Overview ¶
Package sqlproxy provides a SQL query interface that wraps SQLite and captures write operations for sync. Apps use standard SQL (Exec/Query/QueryRow); writes are detected and logged for the sync engine to broadcast.
Index ¶
- type Migration
- type OnWriteEventFunc
- type OnWriteFunc
- type Proxy
- func (p *Proxy) Close() error
- func (p *Proxy) Exec(ctx context.Context, query string, args ...any) (sql.Result, error)
- func (p *Proxy) Migrate(ctx context.Context, migrations []Migration) error
- func (p *Proxy) Query(ctx context.Context, query string, args ...any) (*sql.Rows, error)
- func (p *Proxy) QueryRow(ctx context.Context, query string, args ...any) *sql.Row
- type WriteEntry
- type WriteEvent
- type WriteOp
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type OnWriteEventFunc ¶
type OnWriteEventFunc func(ctx context.Context, event WriteEvent) error
OnWriteEventFunc is called with structured write events including table name.
type OnWriteFunc ¶
type OnWriteFunc func(entry WriteEntry)
OnWriteFunc is called when a write operation is detected (legacy).
type Proxy ¶
type Proxy struct {
WriteLog []WriteEntry // captured writes (for sync engine to consume)
OnWrite OnWriteFunc // optional legacy callback
OnWriteEvent OnWriteEventFunc // optional structured callback with table name
// contains filtered or unexported fields
}
Proxy wraps a SQLite database and intercepts write operations.
func Open ¶
Open creates a new Proxy backed by a SQLite database at the given path. Use ":memory:" for an in-memory database.
func (*Proxy) Exec ¶
Exec executes a SQL statement. If the statement is a write (INSERT/UPDATE/DELETE), it is recorded in WriteLog for the sync engine.
type WriteEntry ¶
WriteEntry records a detected write operation for sync.
type WriteEvent ¶
type WriteEvent struct {
Table string // target table name
Op WriteOp // INSERT, UPDATE, DELETE
SQL string // original SQL statement
}
WriteEvent is a structured write event with table name extracted.