Type alias EnsurePersistentIndexOptions

EnsurePersistentIndexOptions: {
    cacheEnabled?: boolean;
    deduplicate?: boolean;
    estimates?: boolean;
    fields: string[];
    inBackground?: boolean;
    name?: string;
    sparse?: boolean;
    storedValues?: string[];
    type: "persistent";
    unique?: boolean;
}

Options for creating a persistent index.

Type declaration

  • Optional cacheEnabled?: boolean

    If set to true, an in-memory hash cache will be put in front of the persistent index.

    Default: false

  • Optional deduplicate?: boolean

    If set to false, inserting duplicate index values from the same document will lead to a unique constraint error if this is a unique index.

    Default: true

  • Optional estimates?: boolean

    If set to false, index selectivity estimates will be disabled for this index.

    Default: true

  • fields: string[]

    An array of attribute paths.

  • Optional inBackground?: boolean

    If set to true, the index will be created in the background to reduce the write-lock duration for the collection during index creation.

    Default: false

  • Optional name?: string

    A unique name for this index.

  • Optional sparse?: boolean

    If set to true, the index will omit documents that do not contain at least one of the attribute paths in fields and these documents will be ignored for uniqueness checks.

    Default: false

  • Optional storedValues?: string[]

    An array of attribute paths that will be stored in the index but can not be used for index lookups or sorting but can avoid full document lookups.

  • type: "persistent"

    Type of this index.

  • Optional unique?: boolean

    If set to true, a unique index will be created.

    Default: false