# Aggregates inside datalog filters

**URL:** <https://forum.datomic.com/t/aggregates-inside-datalog-filters/195>\
**Category:** General\
**Created:** [November 14, 2017, 4:22pm UTC](https://forum.datomic.com/t/aggregates-inside-datalog-filters/195 "2017-11-14T16:22:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dustingetz](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.datomic.com/dustingetz/32/56_2.png) [@dustingetz](https://forum.datomic.com/u/dustingetz)\
**Post date:** [November 14, 2017, 4:22pm UTC](https://forum.datomic.com/t/aggregates-inside-datalog-filters/195/1 "2017-11-14T16:22:17Z")

</div>

Can this post-query filter be done entirely in a peer-server?

```auto
(->> $
     (d/q '[:find (count ?fe) ?e :where
            [?e :request/type]
            [?e :link-query/find-element ?fe]])
     (filter #(< 1 (first %)))
     (map second))

```

---

<div class="post-metadata">

**Author:** ![marshall](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.datomic.com/marshall/32/48_2.png) [@marshall](https://forum.datomic.com/u/marshall)\
**Post date:** [November 14, 2017, 7:33pm UTC](https://forum.datomic.com/t/aggregates-inside-datalog-filters/195/2 "2017-11-14T19:33:40Z")

</div>

Using the Client API (i.e. with peer-server) you would need to get the result of the query from the client API call then do the filter and map in your application code.
