module
Memo::SourceRegistry
Extended Modules
Defined in:
memo/source_registry.crInstance Method Summary
-
#create(db : DB::Database, source_type : String) : Int64
Create a source with no external ID (memo-managed)
-
#delete(db : DB::Database, source_type : String, external_id : ExternalId) : Bool
Delete a source record and return whether it existed
-
#delete_by_id(db : DB::Database, internal_id : Int64) : Bool
Delete source by internal ID
-
#get_external(db : DB::Database, internal_id : Int64) : Tuple(String, ExternalId | Nil) | Nil
Get external ID and source_type from internal ID
-
#get_internal(db : DB::Database, source_type : String, external_id : ExternalId) : Int64 | Nil
Get internal ID for an external source
-
#get_internal_any_type(db : DB::Database, external_id : ExternalId) : Int64 | Nil
Get internal ID without source_type filter
-
#list(db : DB::Database, source_type : String, limit : Int32 = 100, offset : Int32 = 0) : Array(Tuple(Int64, ExternalId | Nil))
List all sources for a given type, ordered by external ID
-
#resolve(db : DB::Database, source_type : String, external_id : ExternalId) : Int64
Resolve external ID to internal ID, creating source record if needed
Instance Method Detail
Create a source with no external ID (memo-managed)
Returns the internal (database) ID for the new source.
Delete a source record and return whether it existed
Note: This only deletes the source registry entry. Caller is responsible for cleaning up related data (chunks, texts, etc.)
Get external ID and source_type from internal ID
Returns tuple of (source_type, external_id) or nil if not found. external_id may be nil if source has no external ID (memo-managed).
Get internal ID for an external source
Returns nil if source doesn't exist (unlike resolve, doesn't create).
Get internal ID without source_type filter
Searches integer, text, and blob IDs. Returns first match. Use when source_type is unknown or when IDs are globally unique.
List all sources for a given type, ordered by external ID
For integer IDs, returns sorted by external_int (chronological). For text IDs, returns sorted by external_text (alphabetical). Sources without external IDs are included with nil external_id.
Resolve external ID to internal ID, creating source record if needed
Returns the internal (database) ID for the given source.