userver: userver/ydb/types.hpp Source File
Loading...
Searching...
No Matches
types.hpp
1#pragma once
2
3#include <chrono>
4#include <cstdint>
5#include <string>
6#include <variant>
7#include <vector>
8
9#include <userver/formats/json_fwd.hpp>
10#include <userver/utils/strong_typedef.hpp>
11
12USERVER_NAMESPACE_BEGIN
13
14namespace ydb {
15
16/*
17 * YDB type | C++ type
18 * ------------------------------
19 * Bool | bool
20 * Int8 | N/A
21 * Uint8 | N/A
22 * Int16 | N/A
23 * Uint16 | N/A
24 * Int32 | std::int32_t
25 * Uint32 | std::uint32_t
26 * Int64 | std::int64_t
27 * Uint64 | std::uint64_t
28 * Float | N/A
29 * Double | double
30 * Date | N/A
31 * Datetime | N/A
32 * Timestamp | std::chrono::system_clock::time_point
33 * Interval | N/A
34 * TzDate | N/A
35 * TzDatetime | N/A
36 * TzTimestamp | N/A
37 * String | std::string
38 * Utf8 | ydb::Utf8
39 * Yson | N/A
40 * Json | formats::json::Value
41 * Uuid | N/A
42 * JsonDocument | ydb::JsonDocument
43 * DyNumber | N/A
44 *
45 */
46
47using Timestamp = std::chrono::system_clock::time_point;
48
49class Utf8Tag {};
50using Utf8 = utils::StrongTypedef<Utf8Tag, std::string>;
51
52class JsonDocumentTag {};
53using JsonDocument =
54 utils::StrongTypedef<JsonDocumentTag, formats::json::Value>;
55
56using InsertColumnValue = std::variant<
57 std::string, bool, std::int32_t, std::uint32_t, std::int64_t, std::uint64_t,
58 double, Utf8, Timestamp, std::optional<std::string>, std::optional<bool>,
59 std::optional<std::int32_t>, std::optional<std::uint32_t>,
60 std::optional<std::int64_t>, std::optional<std::uint64_t>,
61 std::optional<double>, std::optional<Utf8>, std::optional<Timestamp>>;
62
63struct InsertColumn {
64 std::string name;
65 InsertColumnValue value;
66};
67
68using InsertRow = std::vector<InsertColumn>;
69
70} // namespace ydb
71
72USERVER_NAMESPACE_END