# Relationship metadata vs. link metadata

**URL:** <https://discuss.jsonapi.org/t/relationship-metadata-vs-link-metadata/941>\
**Category:** Uncategorized\
**Created:** [April 1, 2017, 6:59pm UTC](https://discuss.jsonapi.org/t/relationship-metadata-vs-link-metadata/941 "2017-04-01T18:59:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dougo](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.jsonapi.org/dougo/32/386_2.png) [@dougo](https://discuss.jsonapi.org/u/dougo)\
**Post date:** [April 1, 2017, 6:59pm UTC](https://discuss.jsonapi.org/t/relationship-metadata-vs-link-metadata/941/1 "2017-04-01T18:59:09Z")

</div>

The 1.0 spec has the following example for metadata on a relationship’s `related` link:

```
"links": {
  "related": {
    "href": "http://example.com/articles/1/comments",
    "meta": {
      "count": 10
    }
  }
}

```

I would have expected the `count` to be on the relationship itself, though, not just the `related` link:

```
"relationships": {
  "comments": {  
    "links": {
      "related": "http://example.com/articles/1/comments"
    },
    "meta": {
      "count": 10
    }
  }
}

```

I realize this is just an example to demonstrate that links can be objects and not just strings, and is probably not meant to be a recommendation for where to put a `count` property. But I want to do exactly that, and I’m wondering if this example came from a real-world use case. Has anyone done something like this?

---

<div class="post-metadata">

**Author:** ![OliverSalzburg](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.jsonapi.org/oliversalzburg/32/416_2.png) [@OliverSalzburg](https://discuss.jsonapi.org/u/OliverSalzburg)\
**Post date:** [June 21, 2017, 3:17pm UTC](https://discuss.jsonapi.org/t/relationship-metadata-vs-link-metadata/941/2 "2017-06-21T15:17:38Z")

</div>

In your suggested case, it is no longer clear what the `count` refers to in all use cases. Consider there being more links.

In the first example, I would instantly assume that it means that there are 10 comments on the article, as there is meta information available on the `related` link.

In the second example, if there were more links, it is unclear what the count is referring to.

---

<div class="post-metadata">

**Author:** ![dougo](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.jsonapi.org/dougo/32/386_2.png) [@dougo](https://discuss.jsonapi.org/u/dougo)\
**Post date:** [June 24, 2017, 9:39pm UTC](https://discuss.jsonapi.org/t/relationship-metadata-vs-link-metadata/941/3 "2017-06-24T21:39:46Z")

</div>

The count refers to the number of comment resources in the collection indicated by the “comments” relationship object. I suppose you could have multiple links to different resources that represent the collection of comments, but the “comments” object is still conceptually one collection with a fixed count of content resources. In particular, the “count” value would equal the size of the array value of a “data” property that would be included in the “comments” object if requested. Which is why I think it should appear at that same level in the document.

---

<div class="post-metadata">

**Author:** ![michaelhibay](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.jsonapi.org/michaelhibay/32/405_2.png) [@michaelhibay](https://discuss.jsonapi.org/u/michaelhibay)\
**Post date:** [June 26, 2017, 6:00pm UTC](https://discuss.jsonapi.org/t/relationship-metadata-vs-link-metadata/941/4 "2017-06-26T18:00:29Z")

</div>

Consider the case of public or private comments. In your example, if the rel name is ‘public’ and ‘private’ with a total count as you suggest of 12, you would have no indication of how many public comments were related. You could do both ways, but this would be redundant.
