1#ifndef DITTO_DQL_QUERY_RESULT_H
2#define DITTO_DQL_QUERY_RESULT_H
4#include "DocumentId.hpp"
12#include <unordered_map>
15using dittoffi_query_result_t =
struct dittoffi_query_result;
16using dittoffi_query_result_item_t =
struct dittoffi_query_result_item;
19using ValueMap = std::unordered_map<std::string, any>;
28class QueryResultItem {
29 friend class QueryResult;
33 explicit QueryResultItem(dittoffi_query_result_item_t *raw);
35 explicit QueryResultItem(
const nlohmann::json &json_dict);
37 std::shared_ptr<dittoffi_query_result_item> raw;
38 mutable std::shared_ptr<ValueMap> materialized_value;
39 mutable std::unique_ptr<std::mutex>
synchronized;
55 std::shared_ptr<ValueMap>
value()
const;
113 static QueryResultItem from_json(
const nlohmann::json &json_dict);
124 friend class StoreObserver;
125 friend class Transaction;
126 explicit QueryResult(dittoffi_query_result_t *raw);
127 std::shared_ptr<dittoffi_query_result_t> raw;
144 std::vector<QueryResultItem>
items()
const;
std::unique_ptr< uint64_t > get_commit_id() const
The commit ID associated with this query result, if any.
QueryResultItem get_item(size_t index) const
Returns the matching QueryResultItem.
std::vector< QueryResultItem > items() const
std::vector< DocumentId > mutated_document_ids() const
IDs of documents that were mutated by the DQL query. Empty array if no documents have been mutated.
size_t item_count() const
Represents a single match of a DQL query, similar to a "row" in SQL terms. It is a reference type ser...
Definition QueryResult.hpp:28
void dematerialize()
Releases the materialized value from memory. No-op if item is not materialized.
std::string json_string() const
Returns the content of the item as a JSON string.
std::shared_ptr< ValueMap > value() const
Returns the content as a materialized value map.
std::vector< uint8_t > cbor_data() const
Returns the content of the item as CBOR data.
bool is_materialized() const
Returns true if value is currently held materialized in memory, otherwise returns false.
void materialize()
Loads the CBOR representation of the item's content, decodes it as a dictionary so it can be accessed...
Definition StoreObserver.hpp:43
Namespace for the Ditto C++ SDK types and functions.
Definition AbstractDocumentPath.hpp:19