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 = utils::StrongTypedef<JsonDocumentTag, formats::json::Value>;
54
55using InsertColumnValue = std::variant<
56 std::string,
57 bool,
58 std::int32_t,
59 std::uint32_t,
60 std::int64_t,
61 std::uint64_t,
62 double,
63 Utf8,
64 Timestamp,
65 std::optional<std::string>,
66 std::optional<bool>,
67 std::optional<std::int32_t>,
68 std::optional<std::uint32_t>,
69 std::optional<std::int64_t>,
70 std::optional<std::uint64_t>,
71 std::optional<double>,
72 std::optional<Utf8>,
73 std::optional<Timestamp>>;
74
75struct InsertColumn {
76 std::string name;
77 InsertColumnValue value;
78};
79
80using InsertRow = std::vector<InsertColumn>;
81
82} // namespace ydb
83
84USERVER_NAMESPACE_END