# Get all comments linked to an entity

**URL:** <https://community.fibery.io/t/get-all-comments-linked-to-an-entity/8497>\
**Category:** Get Help\
**Tags:** api\
**Created:** [March 24, 2025, 12:33am UTC](https://community.fibery.io/t/get-all-comments-linked-to-an-entity/8497 "2025-03-24T00:33:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![helloitse](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/helloitse/32/498_2.png) [@helloitse](https://community.fibery.io/u/helloitse)\
**Post date:** [March 24, 2025, 12:33am UTC](https://community.fibery.io/t/get-all-comments-linked-to-an-entity/8497/1 "2025-03-24T00:33:17Z")

</div>

I’ve tried to reverse engineer this one from the network logs but some examples or documentation would really help here.  
I’m trying to get the document secrets of all comments linked to a specific entity. Here’s what I have so far, and it returns no results. Can anyone share a working api call?

```auto
[
  {
    "command": "fibery.entity/query",
    "args": {
      "query": {
        "q/from": "comments/comment",
        "q/where": [
          "=",
          ["comments/parent", "fibery/id"],
          "$entityId"
        ],
        "q/select": {
          "fibery/id": ["fibery/id"],
          "comment/document-secret": ["comment/document-secret"],
          "fibery/creation-date": ["fibery/creation-date"],
          "fibery/created-by": {
            "user/name": ["fibery/created-by", "user/name"],
            "user/email": ["fibery/created-by", "user/email"]
          }
        },
        "q/limit": "q/no-limit"
      },
      "params": {
        "$entityId": "{{ID}}"
      }
    }
  }
]

```

---

<div class="post-metadata">

**Author:** ![Viktar\_Zhuk](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/viktar_zhuk/32/1934_2.png) [@Viktar\_Zhuk](https://community.fibery.io/u/Viktar_Zhuk)\
**Post date:** [March 24, 2025, 5:27pm UTC](https://community.fibery.io/t/get-all-comments-linked-to-an-entity/8497/2 "2025-03-24T17:27:48Z")

</div>

Hi @helloitse

If you check your ws’s Schema, you will see that `comments/parent` has a type of `comments/comment` it encodes replies of top level comments. Unfortunately there is no polymorphic relation from a Comment to it’s parent Entity, but you can go the other way around.

```auto
  {
    "command": "fibery.entity/query",
    "args": {
      "query": {
        "q/from": "Security Target/Target Database",
        "q/select": {
          "comments/comments": {
            "q/from": ["comments/comments"],
            "q/select": {
              "fibery/id": ["fibery/id"],
              "fibery/public-id": ["fibery/public-id"],
              "fibery/creation-date": ["fibery/creation-date"],
              "comment/document-secret": ["comment/document-secret"],
              "comments/parent": {"fibery/id": ["comments/parent", "fibery/id"]},
              "fibery/created-by": {
                "fibery/id": ["fibery/created-by", "fibery/id"],
                "user/email": ["fibery/created-by", "user/email"],
                "user/name": ["fibery/created-by", "user/name"],
                "avatar/avatars": {
                  "q/from": ["fibery/created-by", "avatar/avatars"],
                  "q/limit": "q/no-limit",
                  "q/select": {
                    "fibery/id": ["fibery/id"],
                    "fibery/name": ["fibery/name"],
                    "fibery/content-type": ["fibery/content-type"],
                    "fibery/secret": ["fibery/secret"],
                  },
                },
              },
            },
            "q/limit": "q/no-limit",
          },
        },
        "q/where": ["=", ["fibery/id"], "$entityId"],
        "q/limit": 1,
      },
      "params": {"$entityId": "1"},
    },
  },
];

```

hope this helps
