Added ability to remove all records from the database.

This commit is contained in:
2026-01-16 23:13:10 -05:00
parent cb4488ee58
commit d850c5a6e0
2 changed files with 38 additions and 0 deletions

View File

@@ -62,6 +62,7 @@ while (true)
Console.WriteLine(" 2. Search for similar addresses");
Console.WriteLine(" 3. Get all addresses");
Console.WriteLine(" 4. Exit");
Console.WriteLine(" 5. Delete all records");
Console.Write("Select an option: ");
var option = Console.ReadLine()?.Trim();
@@ -83,6 +84,9 @@ while (true)
case "3":
await GetAllAddressesAsync(qdrantService);
break;
case "5":
await DeleteAllAddressesAsync(qdrantService);
break;
default:
Console.WriteLine("Invalid option. Please try again.");
break;
@@ -231,4 +235,32 @@ async Task GetAllAddressesAsync(IQdrantService? qdrantService)
{
Console.WriteLine($"Error retrieving addresses: {ex.Message}");
}
}
async Task DeleteAllAddressesAsync(IQdrantService? qdrantService)
{
if (qdrantService == null)
{
Console.WriteLine("Deleting all records is not available because Qdrant is not connected.");
return;
}
Console.Write("Are you sure you want to delete ALL records? This cannot be undone. (yes/no): ");
var confirmation = Console.ReadLine()?.Trim().ToLower();
if (confirmation != "yes")
{
Console.WriteLine("Deletion cancelled.");
return;
}
try
{
await qdrantService.DeleteAllAddressesAsync();
Console.WriteLine("All records have been deleted successfully.");
}
catch (Exception ex)
{
Console.WriteLine($"Error deleting records: {ex.Message}");
}
}