# How to filter fields of nested objects (collectionlink)?

**URL:** <https://discourse.getcockpit.com/t/how-to-filter-fields-of-nested-objects-collectionlink/1794>\
**Category:** Support\
**Created:** [January 12, 2021, 10:13pm UTC](https://discourse.getcockpit.com/t/how-to-filter-fields-of-nested-objects-collectionlink/1794 "2021-01-12T22:13:43Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Metelyoff](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/metelyoff/32/762_2.png) [@Metelyoff](https://discourse.getcockpit.com/u/Metelyoff)\
**Post date:** [January 12, 2021, 10:13pm UTC](https://discourse.getcockpit.com/t/how-to-filter-fields-of-nested-objects-collectionlink/1794/1 "2021-01-12T22:13:43Z")

</div>

Exaple request and response:

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/getcockpit/original/1X/9766d1891270396eac0afdb3545bfc278747c3b7.png)  
NOTE: by arrow marked fields which need to hide for example

---

<div class="post-metadata">

**Author:** ![pixelkarma](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/pixelkarma/32/748_2.png) [@pixelkarma](https://discourse.getcockpit.com/u/pixelkarma)\
**Post date:** [January 13, 2021, 6:36pm UTC](https://discourse.getcockpit.com/t/how-to-filter-fields-of-nested-objects-collectionlink/1794/2 "2021-01-13T18:36:34Z")

</div>

You would probably need to make your own middleware script to request from cockpit, filter, and return.

---

<div class="post-metadata">

**Author:** ![serjoscha87](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/serjoscha87/32/151_2.png) [@serjoscha87](https://discourse.getcockpit.com/u/serjoscha87)\
**Post date:** [January 13, 2021, 7:38pm UTC](https://discourse.getcockpit.com/t/how-to-filter-fields-of-nested-objects-collectionlink/1794/3 "2021-01-13T19:38:22Z")

</div>

You do not need a middleware… You can just create api endpoints (which are reflected onto a php-script) a very simple way:

- [How to create custom API Endpoints - #5 by artur](https://discourse.getcockpit.com/t/how-to-create-custom-api-endpoints/202/5)
- A small but concrete example:
  - [How to get quantity number of my entries - #3 by raffaelj](https://discourse.getcockpit.com/t/how-to-get-quantity-number-of-my-entries/1361/3)
  - =\> [cockpit-scripts/count.php at master · raffaelj/cockpit-scripts · GitHub](https://github.com/raffaelj/cockpit-scripts/blob/master/custom-api-endpoints/count.php)

---

<div class="post-metadata">

**Author:** ![Metelyoff](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/metelyoff/32/762_2.png) [@Metelyoff](https://discourse.getcockpit.com/u/Metelyoff)\
**Post date:** [January 13, 2021, 7:50pm UTC](https://discourse.getcockpit.com/t/how-to-filter-fields-of-nested-objects-collectionlink/1794/4 "2021-01-13T19:50:07Z")

</div>

Ok. Thank you! I will try, although I am not php developer 🙂  
I thought it configurable in the cockpit.

---

<div class="post-metadata">

**Author:** ![Metelyoff](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/metelyoff/32/762_2.png) [@Metelyoff](https://discourse.getcockpit.com/u/Metelyoff)\
**Post date:** [January 13, 2021, 7:57pm UTC](https://discourse.getcockpit.com/t/how-to-filter-fields-of-nested-objects-collectionlink/1794/5 "2021-01-13T19:57:11Z")

</div>

Ok. Thanks for modest answer 🙂 I thought, it can be filtering inside “fields” POST body. For example:  
{  
“fields”: {  
“active”: 0,  
“tests.active”: 0  
or  
“tests”: {  
“active”: 0  
}  
},  
“populate”: 1  
}

---

<div class="post-metadata">

**Author:** ![pixelkarma](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/pixelkarma/32/748_2.png) [@pixelkarma](https://discourse.getcockpit.com/u/pixelkarma)\
**Post date:** [January 13, 2021, 8:23pm UTC](https://discourse.getcockpit.com/t/how-to-filter-fields-of-nested-objects-collectionlink/1794/6 "2021-01-13T20:23:34Z")

</div>

so, software in the middle 😉
