Couchbase C++ SDK 1.0.2 (rev. 51f4775)
Loading...
Searching...
No Matches
binary_collection.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2/*
3 * Copyright 2020-Present Couchbase, Inc.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#pragma once
19
22#include <couchbase/error.hxx>
25
26#include <future>
27#include <memory>
28
29namespace couchbase
30{
31class collection;
32#ifndef COUCHBASE_CXX_CLIENT_DOXYGEN
33namespace core
34{
35class cluster;
36} // namespace core
37class binary_collection_impl;
38#endif
39
47{
48public:
57 [[nodiscard]] auto bucket_name() const -> const std::string&;
58
67 [[nodiscard]] auto scope_name() const -> const std::string&;
68
77 [[nodiscard]] auto name() const -> const std::string&;
78
97 void append(std::string document_id,
98 std::vector<std::byte> data,
99 const append_options& options,
100 append_handler&& handler) const;
101
120 [[nodiscard]] auto append(std::string document_id,
121 std::vector<std::byte> data,
122 const append_options& options) const
123 -> std::future<std::pair<error, mutation_result>>;
124
145 void prepend(std::string document_id,
146 std::vector<std::byte> data,
147 const prepend_options& options,
148 prepend_handler&& handler) const;
149
168 [[nodiscard]] auto prepend(std::string document_id,
169 std::vector<std::byte> data,
170 const prepend_options& options) const
171 -> std::future<std::pair<error, mutation_result>>;
172
190 void increment(std::string document_id,
191 const increment_options& options,
192 increment_handler&& handler) const;
193
209 [[nodiscard]] auto increment(std::string document_id, const increment_options& options) const
210 -> std::future<std::pair<error, counter_result>>;
211
229 void decrement(std::string document_id,
230 const decrement_options& options,
231 decrement_handler&& handler) const;
232
248 [[nodiscard]] auto decrement(std::string document_id, const decrement_options& options) const
249 -> std::future<std::pair<error, counter_result>>;
250
251private:
252 friend class collection;
253
254 binary_collection(core::cluster core,
255 std::string_view bucket_name,
256 std::string_view scope_name,
257 std::string_view name);
258
259 std::shared_ptr<binary_collection_impl> impl_;
260};
261} // namespace couchbase
Allows to perform certain operations on non-JSON documents.
Definition binary_collection.hxx:47
auto bucket_name() const -> const std::string &
Returns name of the bucket where the collection is defined.
void append(std::string document_id, std::vector< std::byte > data, const append_options &options, append_handler &&handler) const
Appends binary content to the document.
void increment(std::string document_id, const increment_options &options, increment_handler &&handler) const
Increments the counter document by one or the number defined in the options.
void prepend(std::string document_id, std::vector< std::byte > data, const prepend_options &options, prepend_handler &&handler) const
Prepends binary content to the document.
auto name() const -> const std::string &
Returns name of the collection.
void decrement(std::string document_id, const decrement_options &options, decrement_handler &&handler) const
Decrements the counter document by one or the number defined in the options.
auto scope_name() const -> const std::string &
Returns name of the scope where the collection is defined.
The cluster is the main entry point when connecting to a Couchbase cluster.
Definition cluster.hxx:60
The collection provides access to all collection APIs.
Definition collection.hxx:70
Represents result of counter operations.
Definition counter_result.hxx:35
Definition error.hxx:30
Represents result of mutation operations.
Definition mutation_result.hxx:35
Represents a single item from the result of collection::scan()
Definition allow_querying_search_index_options.hxx:28
std::function< void(error, counter_result)> increment_handler
The signature for the handler of the binary_collection::increment() operation.
Definition increment_options.hxx:145
std::function< void(error, counter_result)> decrement_handler
The signature for the handler of the binary_collection::decrement() operation.
Definition decrement_options.hxx:144
std::function< void(error, mutation_result)> prepend_handler
The signature for the handler of the binary_collection::prepend() operation.
Definition prepend_options.hxx:103
std::function< void(error, mutation_result)> append_handler
The signature for the handler of the binary_collection::append() operation.
Definition append_options.hxx:102
Options for binary_collection::append().
Definition append_options.hxx:41
Options for collection#decrement().
Definition decrement_options.hxx:37
Options for binary_collection::increment().
Definition increment_options.hxx:38
Options for binary_collection::prepend().
Definition prepend_options.hxx:41