# No-object type (eg. int, bool, float) becomes an \` Object\` type

**URL:** <https://discuss.dgraph.io/t/no-object-type-eg-int-bool-float-becomes-an-object-type/17776>\
**Category:** Dgraph\
**Tags:** kind:question, dgraph\
**Created:** [September 14, 2022, 2:24pm UTC](https://discuss.dgraph.io/t/no-object-type-eg-int-bool-float-becomes-an-object-type/17776 "2022-09-14T14:24:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lizonglingo](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/lizonglingo/32/10021_2.png) [@lizonglingo](https://discuss.dgraph.io/u/lizonglingo)\
**Post date:** [September 14, 2022, 2:24pm UTC](https://discuss.dgraph.io/t/no-object-type-eg-int-bool-float-becomes-an-object-type/17776/1 "2022-09-14T14:24:21Z")

</div>

I defined the **schema** and **go structure** as follows:

```golang
const DNODE_SCHEMA = `
	name: string @index(exact) .
	downstream: [uid] @reverse @count .
	deployment: string @index(exact) .
	count_l4: int .
	count_l7: int .
	sum_latency_ms: float .
	since: datetime .
	active: bool .
	reserve: bool .
	type: string .
	type Pod {
		name
		deployment
		downstream
		count_l4
		count_l7
		sum_latency_ms
		since
		active
		reserve
	}
`
type Pod struct {
	Uid string `json:"uid,omitempty"`
	Name string `json:"name,omitempty"`
	DownStream []Pod `json:"downstream,omitempty"`
	Deployment string `json:"deployment,omitempty"` 
	CountL4 int `json:"downstream|count_l4,omitempty"`   
	CountL7 int `json:"downstream|count_l7,omitempty"`    
	SumLatencyMs float64 `json:"downstream|sum_latency_ms,omitempty"` 
	Since time.Time `json:"downstream|since,omitempty"`        
	Active bool `json:"downstream|active,omitempty"` 
	Reserve bool `json:"downstream|reserve,omitempty"`    
}

```

But when I query the nodes recursively, some **facets** become of type `Object`:

```shell
# query
{
  pod(func: has(name)) @recurse(depth: 10) {
    uid
    name
   downstream @facets 
  }
}
# result
{
        "uid": "0xc6",
        "name": "carts-77c79d8f5c-tn4dn",
        "downstream": [
          {
            "uid": "0xc1",
            "name": "orders-b54f99dcf-n2pqj",
            "downstream|active": {
              "0": true
            },
            "downstream|reserve": true,
            ...
            "downstream|count_l7": {
              "1": 1,
              "2": 1,
              "3": 1,
              "4": 1
            }
          },
          {
            "uid": "0xc9",
           ...
            "downstream|since": "2022-09-14T13:42:01.235293866Z",
            "downstream|active": {
              "3": true
            },
            "downstream|sum_latency_ms": 154.48845
          }
        ]
      }

```

## Question

Why do these **non-object** types become **object** types, and what do the keys (eg. “1”, “2”, “4”) in them mean?

How can I avoid this situation and keep the original type when querying recursively?

## Other Information

The information on each edge is re-written many times.

When a facet is written, both nodes of an edge may be the starting point.

The edges are all bidirectional, , and it looks like this:

 ![image](https://canada1.discourse-cdn.com/flex007/uploads/dgraph/original/2X/9/9118bb65f64c3cae0af9081520f5dddb1ff20be0.png)

---

<div class="post-metadata">

**Author:** ![amaster507](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/amaster507/32/4123_2.png) [@amaster507](https://discuss.dgraph.io/u/amaster507)\
**Post date:** [September 14, 2022, 3:17pm UTC](https://discuss.dgraph.io/t/no-object-type-eg-int-bool-float-becomes-an-object-type/17776/2 "2022-09-14T15:17:17Z")

</div>

> [@lizonglingo](#):
>
> The information on each edge is re-written many times.

I wonder if your rewrites are actually rewriting and not just concatenating.

> [@lizonglingo](#):
>
> what do the keys (eg. “1”, “2”, “4”) in them mean?

This lead me to the above notion. I wonder if the keys indicate the version of the value. `2` should have overwritten `1` but instead now you have `1` and `2`, just a theory.

> [@lizonglingo](#):
>
> How can I avoid this situation and keep the original type when querying recursively?

Can you post your mutations? I haven’t actually used facets, but if my above theory is correct, then the problem might be how you are mutating your facets.

---

<div class="post-metadata">

**Author:** ![lizonglingo](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/lizonglingo/32/10021_2.png) [@lizonglingo](https://discuss.dgraph.io/u/lizonglingo)\
**Post date:** [September 14, 2022, 3:27pm UTC](https://discuss.dgraph.io/t/no-object-type-eg-int-bool-float-becomes-an-object-type/17776/3 "2022-09-14T15:27:53Z")

</div>

> [@amaster507](#):
>
> Can you post your mutations? I haven’t actually used facets, but if my above theory is correct, then the problem might be how you are mutating your facets.

Thank you for your attention to this issue.

This is the relevant code that I write **facets** as follow:

```golang
...
edge := model.Pod{
		Uid: upUID, // // a uid of a node (already created), like "0xc1"
		DownStream: []model.Pod{
			{
				Uid: downUID, // a uid of a node (already created), like "0xc2"
				CountL4: info.CountL4, // these fields are not directly associated with existing facets, I just want to replace the existing facets with these new fields
				CountL7: info.CountL7,
				SumLatencyMs: info.SumLatencyMs,
				Since: info.Since,
				Active: info.Active,
				Reserve: info.TwoWay,
			},
		},
	}

	err := dg.UpdateNode(edge)
...

```

And the `UpdateNode()` as follow:

```golang
func (dg *DGO) UpdateNode(pod model.Pod) error {
	mu := &api.Mutation{
		CommitNow: true,
	}
	pb, err := json.Marshal(pod)
	if err != nil {
		dg.Logger.Error("error marshal pod")
		return err
	}

	mu.SetJson = pb
	_, err = dg.DClient.NewTxn().Mutate(context.Background(), mu)
	if err != nil {
		dg.Logger.Error("error mutate update pod node")
		return err
	}

	return nil
}

```
