mongoc_collection_create_index()

Synopsis

bool
mongoc_collection_create_index (mongoc_collection_t      *collection,
                                const bson_t             *keys,
                                const mongoc_index_opt_t *opt,
                                bson_error_t             *error);

Parameters

collection

A mongoc_collection_t.

keys

A bson_t.

opt

A mongoc_index_opt_t.

error

An optional location for a bson_error_t or NULL.

Description

This function will request the creation of a new index.

This function will use the createIndexes command if available on the MongoDB server. If not, it will fallback to inserting into system.indexes for compatibility with MongoDB <= 2.4.

See mongoc_index_opt_t for options on creating indexes.

Errors

Errors are propagated via the error parameter.

Returns

true on success, false on failure and error is set.