Memo::Queries
Abstract query interface for database-backend-specific SQL.
Each backend (SQLite, PostgreSQL) implements all query methods with SQL native to that backend. This avoids placeholder translation and keeps SQL explicit per backend.
Constructors
Class methods
Instance methods
Per chunk of a source: {content_id, pair_id, parent_id, source_type, whether its hash has an embedding, with a stored vector, for the service}
The mark_queue_* methods take the item's text as it was read, and do
nothing if it has changed since: the source was queued again, and the
newer text still needs embedding.
Mark the item done if it still holds text (nothing changed it since
it was read). Returns whether it did.
Remove a service's vectors, journal entries and journal state
Delete the chunks whose embeddings only this service has
Which of hashes have an embedding for the service with a stored
vector (one without has been lost: embed it again)
{embedding id, service id} for every service's embedding of a hash
The chunks of rowids' embeddings that pass the filter clauses, at most
per_embedding of each. An embedding is shared by every chunk with its
text, so its other chunks may belong to sources the filters exclude.
{source_id, path} of the files whose path starts with prefix
Which of candidate_ids pass the filter clauses (looked up by id, so the
cost depends on the number of candidates, not the collection)
Same queries, run on one connection (for use inside a transaction).
{pruned_through, vectors_backfilled}
Distinct embedding ids logged after seq
Embeddings logged for the service after after and through through
that it no longer has (no row, no vector): removals
Insert service with is_default and return ID (for ServiceProvider.create)
Insert a source unless one with this id exists (another writer may have added it since the caller looked). Returns its id, or nil if it existed.
memo_texts rows (databases from before 0.13): {source_id, content, content_hash}
Delete a text unless a source or chunk still points at it
The id of the text with this hash, storing it if new. content nil
stores the hash alone.