Dgo: how to set facet using

Hi

I am unable to set facets using dgo?

No problem setting “ok” via rdf:

  set {
    # box
    _:box <box.name> "Box one" .
    _:box <dgraph.type> "Box" .
    # item_one
    _:item_one <item.name> "Item one" .
    _:item_one <dgraph.type> "Item" .
    _:box <box.items> _:item_one (ok=true) .

I can then query the facet:

{
	boxes(func: type(Box)){
    box.name
    box.items @facets(eq(ok, true)) {
      item.name
    }
  }
}

But if I use the following dgo struct, I can not query the facet(note the box and items are committed - I can just not query with facets):

// ItemEntity --
type ItemEntity struct {
	Name  string   `json:"item.name,omitempty"`
	DType []string `json:"dgraph.type,omitempty"`
}

// BoxEntity --
type BoxEntity struct {
	// Uid   string       `json:"box.uid,omitempty"`
	Name  string       `json:"box.name,omitempty"`
	Items []ItemEntity `json:"box.items,omitempty"`
	Ok    bool         `json:"box.items|box.ok,omitempty"`
	DType []string     `json:"dgraph.type,omitempty"`
}

I have looked at this but still unable to see how to set the json- hope you can help?

Update: One thing I noted is that, in the example code, they create a predicate “Close”, but when using rdf no predicate is created?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.