# What can Datomic Rules do that a Peer query cannot?

**URL:** <https://forum.datomic.com/t/what-can-datomic-rules-do-that-a-peer-query-cannot/554>\
**Category:** General\
**Created:** [July 21, 2018, 4:28pm UTC](https://forum.datomic.com/t/what-can-datomic-rules-do-that-a-peer-query-cannot/554 "2018-07-21T16:28:36Z")\
**Posts on this page:** 3\
**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:** [July 21, 2018, 4:28pm UTC](https://forum.datomic.com/t/what-can-datomic-rules-do-that-a-peer-query-cannot/554/1 "2018-07-21T16:28:36Z")

</div>

The best example of rules I know of is mbrainz graph traversals: [https://github.com/Datomic/mbrainz-sample/blob/master/src/clj/datomic/samples/mbrainz/rules.clj](https://github.com/Datomic/mbrainz-sample/blob/master/src/clj/datomic/samples/mbrainz/rules.clj)

I think graph traversals are much clearer with peer functions, like this: [http://www.hyperfiddle.net/:cookbook!datomic-query-loom/](http://www.hyperfiddle.net/:cookbook!datomic-query-loom/)

I think I understand that rules let you “macroexpand” datoms into new datoms (that don’t actually exist), but peer functions can do the same thing, right?

So what is it that rules do better?

---

<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:** [July 23, 2018, 9:37pm UTC](https://forum.datomic.com/t/what-can-datomic-rules-do-that-a-peer-query-cannot/554/2 "2018-07-23T21:37:56Z")

</div>

Here is another example of rules: [user/group/permissions with rules](https://github.com/Datomic/day-of-datomic/blob/master/tutorial/graph.clj)

---

<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:** [August 1, 2018, 2:46pm UTC](https://forum.datomic.com/t/what-can-datomic-rules-do-that-a-peer-query-cannot/554/3 "2018-08-01T14:46:57Z")

</div>

I am wrong, rules do not expand into datoms, they expand into clauses
