Class MutateInSpec

Represents a sub-operation to perform within a mutate-in operation.

Accessors

Methods

  • Creates a MutateInSpec for adding unique values to an array in a document. This operation will only add values if they do not already exist elsewhere in the array.

    Parameters

    • path: string

      The path to the field.

    • value: any

      The value to add.

    • Optional options: {
          createPath?: boolean;
          multi?: boolean;
          xattr?: boolean;
      }

      Optional parameters for this operation.

      • Optional createPath?: boolean

        Whether or not the path to the field should be created if it does not already exist.

      • Optional multi?: boolean

        If set, this enables an array of values to be passed as value, and each element of the passed array is added to the array.

      • Optional xattr?: boolean

        Whether this operation should reference the document body or the extended attributes data for the document.

    Returns MutateInSpec

  • Creates a MutateInSpec for adding a value to the end of an array in a document.

    Parameters

    • path: string

      The path to the field.

    • value: any

      The value to add.

    • Optional options: {
          createPath?: boolean;
          multi?: boolean;
          xattr?: boolean;
      }

      Optional parameters for this operation.

      • Optional createPath?: boolean

        Whether or not the path to the field should be created if it does not already exist.

      • Optional multi?: boolean

        If set, this enables an array of values to be passed as value, and each element of the passed array is added to the array.

      • Optional xattr?: boolean

        Whether this operation should reference the document body or the extended attributes data for the document.

    Returns MutateInSpec

  • Creates a MutateInSpec for adding a value to a specified location in an array in a document. The path should specify a specific index in the array and the new values are inserted at this location.

    Parameters

    • path: string

      The path to an element of an array.

    • value: any

      The value to add.

    • Optional options: {
          createPath?: boolean;
          multi?: boolean;
          xattr?: boolean;
      }

      Optional parameters for this operation.

      • Optional createPath?: boolean

        Whether or not the path to the field should be created if it does not already exist.

      • Optional multi?: boolean

        If set, this enables an array of values to be passed as value, and each element of the passed array is added to the array.

      • Optional xattr?: boolean

        Whether this operation should reference the document body or the extended attributes data for the document.

    Returns MutateInSpec

  • Creates a MutateInSpec for adding a value to the beginning of an array in a document.

    Parameters

    • path: string

      The path to the field.

    • value: any

      The value to add.

    • Optional options: {
          createPath?: boolean;
          multi?: boolean;
          xattr?: boolean;
      }

      Optional parameters for this operation.

      • Optional createPath?: boolean

        Whether or not the path to the field should be created if it does not already exist.

      • Optional multi?: boolean

        If set, this enables an array of values to be passed as value, and each element of the passed array is added to the array.

      • Optional xattr?: boolean

        Whether this operation should reference the document body or the extended attributes data for the document.

    Returns MutateInSpec

  • Creates a MutateInSpec for decrementing the value of a field in a document.

    Parameters

    • path: string

      The path to the field.

    • value: any

      The value to subtract.

    • Optional options: {
          createPath?: boolean;
          xattr?: boolean;
      }

      Optional parameters for this operation.

      • Optional createPath?: boolean

        Whether or not the path to the field should be created if it does not already exist.

      • Optional xattr?: boolean

        Whether this operation should reference the document body or the extended attributes data for the document.

    Returns MutateInSpec

  • Creates a MutateInSpec for incrementing the value of a field in a document.

    Parameters

    • path: string

      The path to the field.

    • value: any

      The value to add.

    • Optional options: {
          createPath?: boolean;
          xattr?: boolean;
      }

      Optional parameters for this operation.

      • Optional createPath?: boolean

        Whether or not the path to the field should be created if it does not already exist.

      • Optional xattr?: boolean

        Whether this operation should reference the document body or the extended attributes data for the document.

    Returns MutateInSpec

  • Creates a MutateInSpec for inserting a field into the document. Failing if the field already exists at the specified path.

    Parameters

    • path: string

      The path to the field.

    • value: any

      The value to insert.

    • Optional options: {
          createPath?: boolean;
          xattr?: boolean;
      }

      Optional parameters for this operation.

      • Optional createPath?: boolean

        Whether or not the path to the field should be created if it does not already exist.

      • Optional xattr?: boolean

        Whether this operation should reference the document body or the extended attributes data for the document.

    Returns MutateInSpec

  • Creates a MutateInSpec for remove a field from a document.

    Parameters

    • path: string

      The path to the field.

    • Optional options: {
          xattr?: boolean;
      }

      Optional parameters for this operation.

      • Optional xattr?: boolean

        Whether this operation should reference the document body or the extended attributes data for the document.

    Returns MutateInSpec

  • Creates a MutateInSpec for replacing a field on a document. This updates the value of the specified field, failing if the field does not exits.

    Parameters

    • path: string

      The path to the field.

    • value: any

      The value to write.

    • Optional options: {
          xattr?: boolean;
      }

      Optional parameters for this operation.

      • Optional xattr?: boolean

        Whether this operation should reference the document body or the extended attributes data for the document.

    Returns MutateInSpec

  • Creates a MutateInSpec for upserting a field on a document. This updates the value of the specified field, or creates the field if it does not exits.

    Parameters

    • path: string

      The path to the field.

    • value: any

      The value to write.

    • Optional options: {
          createPath?: boolean;
          xattr?: boolean;
      }

      Optional parameters for this operation.

      • Optional createPath?: boolean

        Whether or not the path to the field should be created if it does not already exist.

      • Optional xattr?: boolean

        Whether this operation should reference the document body or the extended attributes data for the document.

    Returns MutateInSpec