1MONGOC_CLIENT_ENCRYPTIONM_OCNRGEOACT_EC_LEINECNRlTYi_PbETmNEoCDnR_gYCoPOcTLILOENC_TCIROENA(T3E)_ENCRYPTED_COLLECTION(3)
2
3
4
6 mongoc_client_encryption_create_encrypted_collection - mon‐
7 goc_client_encryption_create_encrypted_collection()
8
10 mongoc_collection_t*
11 mongoc_client_encryption_create_encrypted_collection (
12 mongoc_client_encryption_t *enc,
13 mongoc_database_t *database,
14 const char *name,
15 const bson_t *in_options,
16 bson_t *out_options,
17 const char *kms_provider,
18 const bson_t *opt_masterKey,
19 bson_error_t *error)
20 BSON_GNUC_WARN_UNUSED_RESULT;
21
22 Create a new collection with Queryable Encryption enabled. Requires a
23 valid mongoc_client_encryption_t object to operate.
24
25 New in version 1.24.0.
26
27
28 SEE ALSO:
29 This function is a convenience API wrapping
30 mongoc_database_create_collection().
31
33 • enc: The mongoc_client_encryption_t to be used to configure encryp‐
34 tion for the new collection.
35
36 • database: The mongoc_database_t in which the new collection will be
37 created.
38
39 • name: The name of the new collection.
40
41 • in_options: The options for the new collection. (See below).
42
43 • out_options: An optional output option for the final create-collec‐
44 tion options. Should point to storage for a bson_t. The pointed-to
45 object must be destroyed by the caller. If NULL, has no effect.
46
47 • kms_provider: The name of the KMS provider to use for generating new
48 data encryption keys for encrypted fields within the collection.
49
50 • opt_masterKey: If provided, used as the masterkey option when data
51 encryption keys need to be created. (See:
52 mongoc_client_encryption_datakey_opts_set_masterkey())
53
54 • error: Optional output parameter pointing to storage for a
55 bson_error_t. If an error occurs, will be initialized with error in‐
56 formation.
57
59 If successful, this function returns a new mongoc_collection_t object.
60 Upon failure, returns NULL and initializes *error with an error indi‐
61 cating the reason for failure. The returned collection object must be
62 freed by the caller.
63
65 The in_options parameter behaves similarly to the opts parameter for
66 mongoc_database_create_collection(), which accepts the options for the
67 create MongoDB command (Documented here). The in_options document ac‐
68 cepted here is different in one important way:
69
70 The $.encryptedFields.fields array is required by this function, and,
71 unlike the schema documented for the create command, accepts a value of
72 null for the keyId parameter on each array element.
73
74 This function has the following as-if effect:
75
76 1. A new set of options O will be created based on in_options.
77
78 2. For each element F in the $.encryptedFields.fields array of O:
79
80 1. If F contains a "keyId": null element, a new data encryption key
81 K_f will be created as-if by calling the
82 mongoc_client_encryption_create_datakey(), using the relevant ar‐
83 guments that were given to mongoc_client_encryption_create_en‐
84 crypted_collection.
85
86 2. The ID of K_f will be used to replace the "keyId": null element
87 within F.
88
89 3. A collection will be created using the options O.
90
91 4. If out_options is not NULL, O will be written to out_options.
92
94 MongoDB, Inc
95
97 2017-present, MongoDB, Inc
98
99
100
101
1021.24.3 MONGOC_CLIAEuNgT_1E7N,CR2Y0P2T3ION_CREATE_ENCRYPTED_COLLECTION(3)