|
| 1 | +:man_page: mongoc_collection_create_indexes_with_opts |
| 2 | + |
| 3 | +mongoc_collection_create_indexes_with_opts() |
| 4 | +============================================ |
| 5 | + |
| 6 | +Synopsis |
| 7 | +-------- |
| 8 | + |
| 9 | +.. code-block:: c |
| 10 | +
|
| 11 | + typedef struct _mongoc_index_model_t mongoc_index_model_t; |
| 12 | + |
| 13 | + mongoc_index_model_t * |
| 14 | + mongoc_index_model_new (const bson_t *keys, const bson_t *opts); |
| 15 | + |
| 16 | + void mongoc_index_model_destroy (mongoc_index_model_t *model); |
| 17 | + |
| 18 | + bool |
| 19 | + mongoc_collection_create_indexes_with_opts (mongoc_collection_t *collection, |
| 20 | + mongoc_index_model_t **models, |
| 21 | + size_t n_models, |
| 22 | + const bson_t *opts, |
| 23 | + bson_t *reply, |
| 24 | + bson_error_t *error); |
| 25 | +
|
| 26 | +Parameters |
| 27 | +---------- |
| 28 | + |
| 29 | +* ``collection``: A :symbol:`mongoc_collection_t`. |
| 30 | +* ``models``: An array of ``mongoc_index_model_t *``. |
| 31 | +* ``n_models``: The number of ``models``. |
| 32 | +* ``opts``: Optional options. |
| 33 | +* ``reply``: An optional location for the server reply to the ``createIndexes`` command. |
| 34 | +* ``error``: An optional location for a :symbol:`bson_error_t <errors>` or ``NULL``. |
| 35 | + |
| 36 | +.. |opts-source| replace:: ``collection`` |
| 37 | + |
| 38 | +.. include:: includes/write-opts.txt |
| 39 | + |
| 40 | +Additional options passed in ``opts`` are appended to the ``createIndexes`` command. See the `MongoDB Manual for createIndexes <https://www.mongodb.com/docs/manual/reference/command/createIndexes/>`_ for all supported options. |
| 41 | + |
| 42 | +If no write concern is provided in ``opts``, the collection's write concern is used. |
| 43 | + |
| 44 | +mongoc_index_model_t |
| 45 | +```````````````````` |
| 46 | +Each ``mongoc_index_model_t`` represents an index to create. ``mongoc_index_model_new`` includes: |
| 47 | + |
| 48 | +* ``keys`` Expected to match the form of the ``key`` field in the `createIndexes <https://www.mongodb.com/docs/manual/reference/command/createIndexes/>`_ command. |
| 49 | +* ``opts`` Optional index options appended as a sibling to the ``key`` field in the `createIndexes <https://www.mongodb.com/docs/manual/reference/command/createIndexes/>`_ command. |
| 50 | + |
| 51 | + |
| 52 | +Description |
| 53 | +----------- |
| 54 | + |
| 55 | +This function wraps around the `createIndexes <https://www.mongodb.com/docs/manual/reference/command/createIndexes/>`_ command. |
| 56 | + |
| 57 | +Errors |
| 58 | +------ |
| 59 | + |
| 60 | +Errors are propagated via the ``error`` parameter. |
| 61 | + |
| 62 | +Returns |
| 63 | +------- |
| 64 | + |
| 65 | +Returns ``true`` if successful. Returns ``false`` and sets ``error`` if there are invalid arguments or a server or network error. |
| 66 | + |
| 67 | +.. seealso:: |
| 68 | + |
| 69 | + | :doc:`manage-collection-indexes`. |
0 commit comments