GetField returns the value of the named document field.
(field string)
| 61 | |
| 62 | // GetField returns the value of the named document field. |
| 63 | func (d Document) GetField(field string) (any, error) { |
| 64 | if d.m != nil { |
| 65 | x, ok := d.m[field] |
| 66 | if !ok { |
| 67 | return nil, gcerr.Newf(gcerr.NotFound, nil, "field %q not found in map", field) |
| 68 | } |
| 69 | return x, nil |
| 70 | } |
| 71 | v, err := d.structField(field) |
| 72 | if err != nil { |
| 73 | return nil, err |
| 74 | } |
| 75 | return v.Interface(), nil |
| 76 | } |
| 77 | |
| 78 | // getDocument gets the value of the given field path, which must be a document. |
| 79 | // If create is true, it creates intermediate documents as needed. |