MutateInSpec.insert constructor

MutateInSpec.insert(
  1. String path,
  2. Object? value, {
  3. bool? createPath,
  4. bool? xattr,
})

Creates a MutateInSpec for inserting a field into the document.

This inserts the value of the specified field, or fails if the field already exists at the specified path.

value must be a JSON-serializable value or a MutateInMacro.

When createPath is true, the path to the field will be created if it does not already exist. Defaults to false.

When xattr is true, this operation references the extended attribute data of the document. Otherwise, it references the document body. Defaults to false.

Implementation

factory MutateInSpec.insert(
  String path,
  Object? value, {
  bool? createPath,
  bool? xattr,
}) {
  return MutateInSpec._create(
    Opcode.dictAdd,
    path,
    value,
    createPath: createPath,
    xattr: xattr,
  );
}