因此,我试图使用实体id来检索最近处理到数据体数据库的项。
然而,当调用(获得后-通过-宰牲口zzzzzzzzz)时,我会得到一个错误。
IllegalArgumentExceptionInfo :db.error/too-few-inputs Query expected 2 inputs but received 1 datomic.error/arg (error.clj:57)
(defn get-post-by-eid [eid]
(d/q '[:find ?title ?content ?tags ?eid
:in $ ?eid
:where
[?eid post/title ?title]
[?eid post/content ?content]
[?eid post/tag ?tags]] (d/db conn)))所以我想我的查询字符串一定是格式错误。
我一直在看http://www.learndatalogtoday.org/chapter/3,但还是不知道我要去哪里。
任何帮助都是非常感谢的(=
发布于 2015-03-05 19:30:28
:in子句指定要将两个数据源传递给q函数。$ ?eid意味着您将传递一个数据库(绑定到$)和一些其他值,这些值将绑定到?eid。
如下所示:
(defn get-post-by-eid [eid]
(d/q '[:find ?title ?content ?tags ?eid
:in $ ?eid
:where
[?eid post/title ?title]
[?eid post/content ?content]
[?eid post/tag ?tags]]
(d/db conn)
eid)) 否则,您的eid参数就无法真正“进入”查询。你必须明确地传递它,那里没有魔法。
https://stackoverflow.com/questions/28885862
复制相似问题