MySQL Connector/C++
MySQL connector library for C and C++ applications
Public Types | Public Member Functions | List of all members
CollectionOptions Class Reference

The CollectionOptions class defines collection create/modify options. More...

Public Types

enum  Option { REUSE = 1 , VALIDATION = 2 , LAST }
 Collection options More...
 

Public Member Functions

 CollectionOptions (DbDoc options)
 Constructor using a document. More...
 
template<typename... Rest>
 CollectionOptions (Option opt, Rest &&... rest)
 Construct CollectionOptions from list of Option and value pairs. More...
 
template<typename... Rest>
void set (Rest &&... rest)
 Set list of option and value pairs. More...
 

Detailed Description

The CollectionOptions class defines collection create/modify options.

Member Enumeration Documentation

◆ Option

enum Option

Collection options

Enumerator
REUSE 

Use existing collection. Expects a boolean value.

VALIDATION 

Collection validation options. Expects CollectionValidation or a json string.

Constructor & Destructor Documentation

◆ CollectionOptions() [1/2]

CollectionOptions ( DbDoc  options)
inline

Constructor using a document.

Document example:

{
"reuseExisting": true,
"validation":
{
"level": "Strict",
"schema":
{
"id": "http://json-schema.org/geo",
"$schema": "http://json-schema.org/draft-06/schema#",
"description": "A geographical coordinate",
"type": "object",
"properties":
{
"latitude":
{
"type": "number"
},
"longitude":
{
"type": "number"
}
},
"required": ["latitude", "longitude"]
}
}
}
}

Document keys:

◆ CollectionOptions() [2/2]

CollectionOptions ( Option  opt,
Rest &&...  rest 
)
inline

Construct CollectionOptions from list of Option and value pairs.

CollectionOptions::Option and CollectionValidation::Option can both be used.

Example:

schema.createCollection(
"collection_test",
R"(
{
"id": "http://json-schema.org/geo",
"$schema": "http://json-schema.org/draft-06/schema#",
"description": "A geographical coordinate",
"type": "object",
"properties":
{
"latitude": {
"type": "number"
},
"longitude": {
"type": "number"
}
},
"required": ["latitude", "longitude"]
})"
);
@ REUSE
Definition: xdevapi.h:312
@ SCHEMA
Definition: xdevapi.h:146
@ LEVEL
Definition: xdevapi.h:146
@ STRICT
Definition: xdevapi.h:136

Member Function Documentation

◆ set()

void set ( Rest &&...  rest)
inline

Set list of option and value pairs.

See also
CollectionOptions::CollectionOptions

The documentation for this class was generated from the following file: