MCPcopy Index your code
hub / github.com/redspread/spread / ResolveRelativeField

Function ResolveRelativeField

pkg/data/fields.go:10–25  ·  view source on GitHub ↗
(field *pb.Field, fieldpath string)

Source from the content-addressed store, hash-verified

8)
9
10func ResolveRelativeField(field *pb.Field, fieldpath string) (resolvedField *pb.Field, err error) {
11 fieldKey, arrIndex, next := nextField(fieldpath)
12 if arrIndex >= 0 {
13 resolvedField, err = getFromArrayField(field, arrIndex)
14 } else if len(fieldKey) > 0 {
15 resolvedField, err = getFromMapField(field, fieldKey)
16 } else {
17 err = fmt.Errorf("could not resolve fieldpath '%s'", fieldpath)
18 }
19
20 // return if err or no more fields to traverse (end of field path)
21 if err != nil || len(next) == 0 {
22 return
23 }
24 return ResolveRelativeField(resolvedField, next)
25}
26
27// FieldValueEquals returns true if the value of the given fields is the same.
28func FieldValueEquals(this, other *pb.Field) bool {

Callers 1

GetFieldFromDocumentFunction · 0.85

Calls 3

nextFieldFunction · 0.85
getFromArrayFieldFunction · 0.85
getFromMapFieldFunction · 0.85

Tested by

no test coverage detected