Set sets the value of the field path in the document. This creates sub-maps as necessary, if possible.
(fp []string, val any)
| 127 | // Set sets the value of the field path in the document. |
| 128 | // This creates sub-maps as necessary, if possible. |
| 129 | func (d Document) Set(fp []string, val any) error { |
| 130 | d2, err := d.getDocument(fp[:len(fp)-1], true) |
| 131 | if err != nil { |
| 132 | return err |
| 133 | } |
| 134 | return d2.SetField(fp[len(fp)-1], val) |
| 135 | } |
| 136 | |
| 137 | // SetField sets the field to value in the document. |
| 138 | func (d Document) SetField(field string, value any) error { |