diff --git a/services/backup/docker-server/contents/server/src/DatabaseEntities/BackupItem.h b/services/backup/docker-server/contents/server/src/DatabaseEntities/BackupItem.h index 82c7b8112..92f0b9e87 100644 --- a/services/backup/docker-server/contents/server/src/DatabaseEntities/BackupItem.h +++ b/services/backup/docker-server/contents/server/src/DatabaseEntities/BackupItem.h @@ -1,69 +1,80 @@ #pragma once #include "Item.h" #include #include namespace comm { namespace network { namespace database { /** + * backup - backups assigned to users along with the data necessary to + * decrypt + * `created` - when the backup was created. This is a search key because + * we want to be able to perform effective queries based on this info + * (for example get me the latest backup, get me backup from some day) + * `attachmentHolders` - this is a list of attachment references + * `recoveryData` - data serialized with protobuf which is described by + * one of the following structures: + * { authType: 'password', pakePasswordCiphertext: string, nonce: string } + * { authType: 'wallet', walletAddress: string, rawMessage: string } + * * this class is used for representing two things: the rows in the main table, * and also the rows in the secondary index * * Needs userID(pk)-created(sk)-index that projects: * userID * backupID * created * recoveryData */ class BackupItem : public Item { std::string userID; std::string backupID; uint64_t created; std::string recoveryData; std::string compactionHolder; std::vector attachmentHolders; void validate() const override; public: static std::string tableName; static const std::string FIELD_USER_ID; static const std::string FIELD_BACKUP_ID; static const std::string FIELD_CREATED; static const std::string FIELD_RECOVERY_DATA; static const std::string FIELD_COMPACTION_HOLDER; static const std::string FIELD_ATTACHMENT_HOLDERS; BackupItem() { } BackupItem( std::string userID, std::string backupID, uint64_t created, std::string recoveryData, std::string compactionHolder, std::vector attachmentHolders); BackupItem(const AttributeValues &itemFromDB); void assignItemFromDatabase(const AttributeValues &itemFromDB) override; std::string getTableName() const override; PrimaryKey getPrimaryKey() const override; PrimaryKeyValue getPrimaryKeyValue() const override; std::string getUserID() const; std::string getBackupID() const; uint64_t getCreated() const; std::string getRecoveryData() const; std::string getCompactionHolder() const; std::vector getAttachmentHolders() const; }; } // namespace database } // namespace network } // namespace comm diff --git a/services/backup/docker-server/contents/server/src/DatabaseEntities/LogItem.h b/services/backup/docker-server/contents/server/src/DatabaseEntities/LogItem.h index 70e23f025..cbc47efeb 100644 --- a/services/backup/docker-server/contents/server/src/DatabaseEntities/LogItem.h +++ b/services/backup/docker-server/contents/server/src/DatabaseEntities/LogItem.h @@ -1,55 +1,63 @@ #pragma once #include "Item.h" #include #include namespace comm { namespace network { namespace database { +/* + * log - a single log record + * `backupID` - id of the backup that this log is assigned to + * `value` - either the value itself which is a dump of a single operation (if + * `persistedInBlob` is false) or the holder to blob (if `persistedInBlob` is + * true) + * `attachmentHolders` - this is a list of attachment references + */ class LogItem : public Item { std::string backupID; std::string logID; bool persistedInBlob; std::string value; std::vector attachmentHolders; void validate() const override; public: static std::string tableName; static const std::string FIELD_BACKUP_ID; static const std::string FIELD_LOG_ID; static const std::string FIELD_PERSISTED_IN_BLOB; static const std::string FIELD_VALUE; static const std::string FIELD_ATTACHMENT_HOLDERS; LogItem() { } LogItem( const std::string backupID, const std::string logID, const bool persistedInBlob, const std::string value, std::vector attachmentHolders); LogItem(const AttributeValues &itemFromDB); void assignItemFromDatabase(const AttributeValues &itemFromDB) override; std::string getTableName() const override; PrimaryKey getPrimaryKey() const override; PrimaryKeyValue getPrimaryKeyValue() const override; std::string getBackupID() const; std::string getLogID() const; bool getPersistedInBlob() const; std::string getValue() const; std::vector getAttachmentHolders() const; }; } // namespace database } // namespace network } // namespace comm