AddFieldMappingsAt adds one or more FieldMappings at the named sub-document. If the named sub-document doesn't yet exist it is created for you. This is a convenience function to make most common mappings more concise. Otherwise, you would: subMapping := NewDocumentMapping() subMapping.AddFieldMa
(property string, fms ...*FieldMapping)
| 289 | // subMapping.AddFieldMapping(fieldMapping) |
| 290 | // parentMapping.AddSubDocumentMapping(property, subMapping) |
| 291 | func (dm *DocumentMapping) AddFieldMappingsAt(property string, fms ...*FieldMapping) { |
| 292 | if dm.Properties == nil { |
| 293 | dm.Properties = make(map[string]*DocumentMapping) |
| 294 | } |
| 295 | sdm, ok := dm.Properties[property] |
| 296 | if !ok { |
| 297 | sdm = NewDocumentMapping() |
| 298 | } |
| 299 | for _, fm := range fms { |
| 300 | sdm.AddFieldMapping(fm) |
| 301 | } |
| 302 | dm.Properties[property] = sdm |
| 303 | } |
| 304 | |
| 305 | // AddFieldMapping adds the provided FieldMapping for this section |
| 306 | // of the document. |