ManifestMetadataTable.h (1845B)
1 // Copyright (c) Microsoft Corporation. 2 // Licensed under the MIT License. 3 #pragma once 4 #include <winget/SQLiteWrapper.h> 5 #include "Microsoft/Schema/ISQLiteIndex.h" 6 #include "Public/winget/RepositorySearch.h" 7 8 #include <string> 9 #include <string_view> 10 #include <vector> 11 12 13 namespace AppInstaller::Repository::Microsoft::Schema::V1_1 14 { 15 // A table for storing arbitrary metadata on individual manifests. 16 // The table and all metadata are optional. 17 struct ManifestMetadataTable 18 { 19 // Determine if the table currently exists in the database. 20 static bool Exists(const SQLite::Connection& connection); 21 22 // Creates the table in the database. 23 static void Create(SQLite::Connection& connection); 24 25 // Drops the table. 26 static void Drop(SQLite::Connection& connection); 27 28 // Gets all metadata associated with the given manifest. 29 // The table must exist. 30 static ISQLiteIndex::MetadataResult GetMetadataByManifestId(const SQLite::Connection& connection, SQLite::rowid_t manifestId); 31 32 // Gets the specific metadata value for the manifest, if it exists. 33 // The table must exist. 34 static std::optional<std::string> GetMetadataByManifestIdAndMetadata(const SQLite::Connection& connection, SQLite::rowid_t manifestId, PackageVersionMetadata metadata); 35 36 // Sets the metadata value for the given manifest. 37 // The table must exist. 38 static void SetMetadataByManifestId(SQLite::Connection& connection, SQLite::rowid_t manifestId, PackageVersionMetadata metadata, std::string_view value); 39 40 // Removes all metadata values for the given manifest. 41 // The table must exist. 42 static void DeleteByManifestId(SQLite::Connection& connection, SQLite::rowid_t manifestId); 43 }; 44 }