Noting differences between Datomic and Datomish.
parent
bf5e9cd597
commit
2f2e7ba3ea
51
Differences-from-Datomic.md
Normal file
51
Differences-from-Datomic.md
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
## fulltext
|
||||||
|
|
||||||
|
The `fulltext` function in Datomish supports sets of attributes or the special keyword `:any`.
|
||||||
|
|
||||||
|
To do a fulltext search that matches page titles or excerpts:
|
||||||
|
|
||||||
|
```
|
||||||
|
[(fulltext $ #{:page/title :page/excerpt} "something") [[?page]]]
|
||||||
|
```
|
||||||
|
|
||||||
|
To match any attribute at all:
|
||||||
|
```
|
||||||
|
[(fulltext $ :any "something") [[?entity]]]
|
||||||
|
```
|
||||||
|
|
||||||
|
## Query inputs, ordering, and limits
|
||||||
|
|
||||||
|
`<q` supports binding values, specifying ordering conditions, and limiting the number of returned results.
|
||||||
|
|
||||||
|
Aggregates can be used as an ordering clause: for an aggregate expression like `(max ?date)`, the ordering column is `_max_date`. In ClojureScript this is a keyword (`:_max_date`); in JS it's a string.
|
||||||
|
|
||||||
|
**ClojureScript**:
|
||||||
|
|
||||||
|
```
|
||||||
|
(d/<q
|
||||||
|
db
|
||||||
|
'[:find ?page ?url ?title ?excerpt
|
||||||
|
:in $ ?time
|
||||||
|
:where
|
||||||
|
[?save :save/page ?page]
|
||||||
|
[?save :save/savedAt ?instant]
|
||||||
|
[(> ?instant ?time)]
|
||||||
|
[?page :page/url ?url]
|
||||||
|
[(get-else $ ?save :save/title "") ?title]
|
||||||
|
[(get-else $ ?save :save/excerpt "") ?excerpt]]
|
||||||
|
{:limit limit
|
||||||
|
:inputs {:time 1234567890}
|
||||||
|
:order-by [[:instant :desc]]})
|
||||||
|
```
|
||||||
|
|
||||||
|
**JS**:
|
||||||
|
|
||||||
|
```
|
||||||
|
await db.q(
|
||||||
|
`[:find ?url (max ?date)
|
||||||
|
:in $
|
||||||
|
:where
|
||||||
|
[?page :page/url ?url]
|
||||||
|
[?page :page/visitedAt ?date]]`,
|
||||||
|
{"limit": 2, "order-by": [["_max_date", "desc"]]});
|
||||||
|
```
|
Loading…
Reference in a new issue