SYNOPSIS

mongoc_collection_t *
mongoc_database_create_collection (mongoc_database_t *database,
                                   const char        *name,
                                   const bson_t      *options,
                                   bson_error_t      *error);

DESCRIPTION

The mongoc_database_create_collection() command will create a new collection on the MongoDB server using the optionally provided parameter options.

name is the name of the collection to be created in database. options is a bson_t containing optional arguments for the create command.

options may support additional parameters in the future. The parameters supported at the time of this writing are:

  • capped is a boolean specifying if the collection should be a capped collection. The default is false.

  • autoIndexId is a boolean specifying if auto index creation should be used. The default is true.

  • size is an integer specifying the maximum size of a capped collection.

  • max is an integer specifying the maximum number of documents in a capped collection. Note that the size limit takes precedence over this limit.

For additional parameters of options, see http://docs.mongodb.org/manual/reference/command/create/

RETURN VALUE

The mongoc_database_create_collection() command will return a newly created mongoc_collection_t if successful, otherwise NULL and error is set.

The resulting mongoc_collection_t should be freed with mongoc_collection_destroy().

ERRORS

errors are returned through error

SEE ALSO

AUTHORS

This page was written by MongoDB, Inc.