MCPcopy
hub / github.com/dgraph-io/dgraph / TypeIDFor

Function TypeIDFor

types/facets/utils.go:159–174  ·  view source on GitHub ↗

TypeIDFor gives TypeID for facet.

(f *api.Facet)

Source from the content-addressed store, hash-verified

157
158// TypeIDFor gives TypeID for facet.
159func TypeIDFor(f *api.Facet) (types.TypeID, error) {
160 switch f.ValType {
161 case api.Facet_INT:
162 return types.IntID, nil
163 case api.Facet_FLOAT:
164 return types.FloatID, nil
165 case api.Facet_BOOL:
166 return types.BoolID, nil
167 case api.Facet_DATETIME:
168 return types.DateTimeID, nil
169 case api.Facet_STRING:
170 return types.StringID, nil
171 default:
172 return types.DefaultID, errors.Errorf("Unrecognized facet type: %v", f.ValType)
173 }
174}
175
176// ValFor converts Facet into types.Val.
177func ValFor(f *api.Facet) (types.Val, error) {

Callers 5

toJSONMethod · 0.92
toRDFMethod · 0.92
applyFacetsTreeFunction · 0.92
ToBinaryFunction · 0.85
ValForFunction · 0.85

Calls 1

ErrorfMethod · 0.45

Tested by

no test coverage detected