Class CreateCollectionOptions


  • public class CreateCollectionOptions
    extends Object
    Options for creating a collection
    • Constructor Detail

      • CreateCollectionOptions

        public CreateCollectionOptions()
      • CreateCollectionOptions

        public CreateCollectionOptions​(JsonObject json)
    • Method Detail

      • getMaxDocuments

        public Long getMaxDocuments()
      • setMaxDocuments

        public CreateCollectionOptions setMaxDocuments​(Long maxDocuments)
        Optional. The maximum number of documents allowed in the capped collection. The size limit takes precedence over this limit. If a capped collection reaches the size limit before it reaches the maximum number of documents, MongoDB removes old documents. If you prefer to use the max limit, ensure that the size limit, which is required for a capped collection, is sufficient to contain the maximum number of documents.
        Parameters:
        maxDocuments -
        Returns:
        CreateCollectionOptions
      • toMongoDriverObject

        public com.mongodb.client.model.CreateCollectionOptions toMongoDriverObject()
        Returns the mongo-java-driver specific object.
        Returns:
        com.mongodb.client.model.CreateCollectionOptions
      • setCapped

        public CreateCollectionOptions setCapped​(Boolean capped)
        Optional. To create a capped collection, specify true. If you specify true, you must also set a maximum size in the size field.
        Parameters:
        capped -
        Returns:
        CreateCollectionOptions
      • getCapped

        public Boolean getCapped()
      • getSizeInBytes

        public Long getSizeInBytes()
      • setSizeInBytes

        public CreateCollectionOptions setSizeInBytes​(Long sizeInBytes)
        Optional. Specify a maximum size in bytes for a capped collection. Once a capped collection reaches its maximum size, MongoDB removes the older documents to make space for the new documents. The size field is required for capped collections and ignored for other collections.
        Parameters:
        sizeInBytes -
        Returns:
        CreateCollectionOptions
      • getStorageEngineOptions

        @Nullable
        public JsonObject getStorageEngineOptions()
      • setStorageEngineOptions

        public CreateCollectionOptions setStorageEngineOptions​(@Nullable
                                                               JsonObject storageEngineOptions)
        Optional. Available for the WiredTiger storage engine only. Allows users to specify configuration to the storage engine on a per-collection basis when creating a collection.
        Parameters:
        storageEngineOptions -
        Returns:
        CreateCollectionOptions
      • getIndexOptionDefaults

        public JsonObject getIndexOptionDefaults()
      • setIndexOptionDefaults

        public CreateCollectionOptions setIndexOptionDefaults​(JsonObject indexOptionDefaults)
        Optional. Allows users to specify a default configuration for indexes when creating a collection.
        Parameters:
        indexOptionDefaults -
        Returns:
        CreateCollectionOptions
      • setCollation

        public CreateCollectionOptions setCollation​(@Nullable
                                                    CollationOptions collation)
        Specifies the default collation for the collection. Collation allows users to specify language-specific rules for string comparison, such as rules for lettercase and accent marks.
        Parameters:
        collation -
        Returns:
        CreateCollectionOptions
      • getExpireAfterSeconds

        public Long getExpireAfterSeconds()
      • setExpireAfterSeconds

        public CreateCollectionOptions setExpireAfterSeconds​(Long expireAfterSeconds)
        Optional. A duration indicating after how long old time-series data should be deleted. Currently, applies only to time-series collections, so if this value is set then so must the time-series options.
        Parameters:
        expireAfterSeconds - duration, in seconds, indicating after how long old time-series data should be deleted
        Returns:
        CreateCollectionOptions
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object