MongoDB C++ Driver mongocxx-3.0.0
Loading...
Searching...
No Matches
index.hpp
1// Copyright 2015 MongoDB Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#pragma once
16
17#include <memory>
18
19#include <bsoncxx/document/view.hpp>
20#include <bsoncxx/stdx/optional.hpp>
21#include <bsoncxx/string/view_or_value.hpp>
22#include <mongocxx/stdx.hpp>
23
24#include <mongocxx/config/prelude.hpp>
25
26namespace mongocxx {
27MONGOCXX_INLINE_NAMESPACE_BEGIN
28
29class collection;
30
31namespace options {
32
38class MONGOCXX_API index {
39 public:
43 class MONGOCXX_API base_storage_options {
44 public:
45 virtual ~base_storage_options();
46
47 private:
48 friend collection;
49 MONGOCXX_PRIVATE virtual int type() const = 0;
50 };
51
55 class MONGOCXX_API wiredtiger_storage_options final : public base_storage_options {
56 public:
58
66
72 const stdx::optional<bsoncxx::string::view_or_value>& config_string() const;
73
74 private:
75 friend collection;
76 MONGOCXX_PRIVATE int type() const override;
77 stdx::optional<bsoncxx::string::view_or_value> _config_string;
78 };
79
80 index();
81
91 void background(bool background);
92
98 const stdx::optional<bool>& background() const;
99
109 void unique(bool unique);
110
116 const stdx::optional<bool>& unique() const;
117
125
131 const stdx::optional<bsoncxx::string::view_or_value>& name() const;
132
142 void sparse(bool sparse);
143
149 const stdx::optional<bool>& sparse() const;
150
158 void storage_options(std::unique_ptr<base_storage_options> storage_options);
159
163 void storage_options(std::unique_ptr<wiredtiger_storage_options> storage_options);
164
174 void expire_after_seconds(std::int32_t expire_after_seconds);
175
181 const stdx::optional<std::int32_t>& expire_after_seconds() const;
182
189 void version(std::int32_t v);
190
196 const stdx::optional<std::int32_t>& version() const;
197
206
212 const stdx::optional<bsoncxx::document::view>& weights() const;
213
222
228 const stdx::optional<bsoncxx::string::view_or_value>& default_language() const;
229
238
244 const stdx::optional<bsoncxx::string::view_or_value>& language_override() const;
245
252 void partial_filter_expression(bsoncxx::document::view partial_filter_expression);
253
259 const stdx::optional<bsoncxx::document::view>& partial_filter_expression() const;
260
267 void twod_sphere_version(std::uint8_t twod_sphere_version);
268
274 const stdx::optional<std::uint8_t>& twod_sphere_version() const;
275
282 void twod_bits_precision(std::uint8_t twod_bits_precision);
283
289 const stdx::optional<std::uint8_t>& twod_bits_precision() const;
290
297 void twod_location_min(double twod_location_min);
298
304 const stdx::optional<double>& twod_location_min() const;
305
312 void twod_location_max(double twod_location_max);
313
319 const stdx::optional<double>& twod_location_max() const;
320
331 void haystack_bucket_size(double haystack_bucket_size);
332
338 const stdx::optional<double>& haystack_bucket_size() const;
339
340 private:
341 friend collection;
342
343 stdx::optional<bool> _background;
344 stdx::optional<bool> _unique;
345 stdx::optional<bsoncxx::string::view_or_value> _name;
346 stdx::optional<bool> _sparse;
347 std::unique_ptr<base_storage_options> _storage_options;
348 stdx::optional<std::int32_t> _expire_after_seconds;
349 stdx::optional<std::int32_t> _version;
350 stdx::optional<bsoncxx::document::view> _weights;
351 stdx::optional<bsoncxx::string::view_or_value> _default_language;
352 stdx::optional<bsoncxx::string::view_or_value> _language_override;
353 stdx::optional<bsoncxx::document::view> _partial_filter_expression;
354 stdx::optional<std::uint8_t> _twod_sphere_version;
355 stdx::optional<std::uint8_t> _twod_bits_precision;
356 stdx::optional<double> _twod_location_min;
357 stdx::optional<double> _twod_location_max;
358 stdx::optional<double> _haystack_bucket_size;
359
360 //
361 // Return the current storage_options setting.
362 //
363 const std::unique_ptr<base_storage_options>& storage_options() const;
364};
365
366} // namespace options
367MONGOCXX_INLINE_NAMESPACE_END
368} // namespace mongocxx
369
370#include <mongocxx/config/postlude.hpp>
A read-only, non-owning view of a BSON document.
Definition view.hpp:33
Class representing a view-or-value variant type for strings.
Definition view_or_value.hpp:36
Class representing server side document groupings within a MongoDB database.
Definition collection.hpp:74
Base class representing the optional storage engine options for indexes.
Definition index.hpp:43
Class representing the optional WiredTiger storage engine options for indexes.
Definition index.hpp:55
void config_string(bsoncxx::string::view_or_value config_string)
Set the WiredTiger configuration string.
const stdx::optional< bsoncxx::string::view_or_value > & config_string() const
The current config_string setting.
Class representing the optional arguments to a MongoDB create index operation.
Definition index.hpp:38
const stdx::optional< std::int32_t > & version() const
The current index version.
void weights(bsoncxx::document::view weights)
For text indexes, sets the weight document.
const stdx::optional< bsoncxx::document::view > & weights() const
The current weights setting.
void storage_options(std::unique_ptr< base_storage_options > storage_options)
Optionally used only in MongoDB 3.0.0 and higher.
const stdx::optional< double > & twod_location_min() const
The current lower inclusive boundary for the longitude and latitude values.
const stdx::optional< bsoncxx::string::view_or_value > & name() const
The current name setting.
const stdx::optional< bsoncxx::string::view_or_value > & default_language() const
The current default_language setting.
void background(bool background)
Whether or not to build the index in the background so that building the index does not block other d...
const stdx::optional< double > & haystack_bucket_size() const
The current haystack_bucket_size setting.
void partial_filter_expression(bsoncxx::document::view partial_filter_expression)
Sets the document for the partial filter expression for partial indexes.
const stdx::optional< bool > & background() const
The current background setting.
const stdx::optional< std::uint8_t > & twod_bits_precision() const
The current precision of the stored geohash value of the location data.
void storage_options(std::unique_ptr< wiredtiger_storage_options > storage_options)
void haystack_bucket_size(double haystack_bucket_size)
For geoHaystack indexes, specify the number of units within which to group the location values; i....
const stdx::optional< bsoncxx::document::view > & partial_filter_expression() const
The current partial_filter_expression setting.
void version(std::int32_t v)
Sets the index version.
void twod_location_min(double twod_location_min)
For 2d indexes, the lower inclusive boundary for the longitude and latitude values.
void twod_sphere_version(std::uint8_t twod_sphere_version)
For 2dsphere indexes, the 2dsphere index version number.
void language_override(bsoncxx::string::view_or_value language_override)
For text indexes, the name of the field, in the collection’s documents, that contains the override la...
void expire_after_seconds(std::int32_t expire_after_seconds)
Set a value, in seconds, as a TTL to control how long MongoDB retains documents in this collection.
const stdx::optional< std::uint8_t > & twod_sphere_version() const
The current twod_sphere_version setting.
const stdx::optional< double > & twod_location_max() const
The current upper inclusive boundary for the longitude and latitude values.
const stdx::optional< bool > & unique() const
The current unique setting.
const stdx::optional< std::int32_t > & expire_after_seconds() const
The current expire_after_seconds setting.
void default_language(bsoncxx::string::view_or_value default_language)
For text indexes, the language that determines the list of stop words and the rules for the stemmer a...
const stdx::optional< bool > & sparse() const
The current sparse setting.
void twod_bits_precision(std::uint8_t twod_bits_precision)
For 2d indexes, the precision of the stored geohash value of the location data.
void name(bsoncxx::string::view_or_value name)
The name of the index.
void sparse(bool sparse)
Whether or not to create a sparse index.
const stdx::optional< bsoncxx::string::view_or_value > & language_override() const
The current name of the field that contains the override language for text indexes.
void unique(bool unique)
Whether or not to create a unique index so that the collection will not accept insertion of documents...
void twod_location_max(double twod_location_max)
For 2d indexes, the upper inclusive boundary for the longitude and latitude values.