userver: userver/ydb/types.hpp Source File
Loading...
Searching...
No Matches
types.hpp
Go to the documentation of this file.
1#pragma once
2
3/// @file userver/ydb/types.hpp
4/// @brief YDB primitive types and insert row column types
5
6#include <chrono>
7#include <cstdint>
8#include <string>
9#include <variant>
10#include <vector>
11
12#include <userver/formats/json_fwd.hpp>
13#include <userver/utils/strong_typedef.hpp>
14
15USERVER_NAMESPACE_BEGIN
16
17namespace ydb {
18
19/*
20 * YDB type | C++ type
21 * ------------------------------
22 * Bool | bool
23 * Int8 | std::int8_t
24 * Uint8 | std::uint8_t
25 * Int16 | std::int16_t
26 * Uint16 | std::uint16_t
27 * Int32 | std::int32_t
28 * Uint32 | std::uint32_t
29 * Int64 | std::int64_t
30 * Uint64 | std::uint64_t
31 * Float | N/A
32 * Double | double
33 * Date | N/A
34 * Datetime | N/A
35 * Timestamp | std::chrono::system_clock::time_point
36 * Interval | N/A
37 * TzDate | N/A
38 * TzDatetime | N/A
39 * TzTimestamp | N/A
40 * String | std::string
41 * Utf8 | ydb::Utf8
42 * Yson | N/A
43 * Json | formats::json::Value
44 * Uuid | N/A
45 * JsonDocument | ydb::JsonDocument
46 * DyNumber | N/A
47 *
48 */
49
50using Timestamp = std::chrono::system_clock::time_point;
51
52class Utf8Tag {};
53using Utf8 = utils::StrongTypedef<Utf8Tag, std::string>;
54
56using JsonDocument = utils::StrongTypedef<JsonDocumentTag, formats::json::Value>;
57
58using InsertColumnValue = std::variant<
59 std::string,
60 bool,
61 std::int8_t,
62 std::uint8_t,
63 std::int16_t,
64 std::uint16_t,
65 std::int32_t,
66 std::uint32_t,
67 std::int64_t,
68 std::uint64_t,
69 double,
70 Utf8,
71 Timestamp,
72 std::optional<std::string>,
73 std::optional<bool>,
74 std::optional<std::int8_t>,
75 std::optional<std::uint8_t>,
76 std::optional<std::int16_t>,
77 std::optional<std::uint16_t>,
78 std::optional<std::int32_t>,
79 std::optional<std::uint32_t>,
80 std::optional<std::int64_t>,
81 std::optional<std::uint64_t>,
82 std::optional<double>,
83 std::optional<Utf8>,
84 std::optional<Timestamp>>;
85
87 std::string name;
88 InsertColumnValue value;
89};
90
91using InsertRow = std::vector<InsertColumn>;
92
93} // namespace ydb
94
95USERVER_NAMESPACE_END