不使用通配符拉取的原因?

Reasons not to use use a wildcard pull?

有什么理由不使用通配符拉取吗?

(defn pull-wild
  "Pulls all attributes of a single entity."
  [db ent-id]
  (d/pull db '[*] ent-id))

比明确说明属性方便多了。

这取决于您的应用程序需要具备哪些属性,它是否是数据密集型的,或者您是否想要提取大量实体。

如果您使用客户端库,您可能希望尽量减少需要通过网络发送的数据。

我猜还有很多其他想法。

但只要速度足够快,我会使用通配符。

弗里克

您可能还对 entity-map 函数 from Tupelo Datomic 感兴趣。给定一个 EID(或查找参考),它将 return 完整记录作为常规 Clojure 映射:

(let [
      ; Retrieve James' attr-val pairs as a map. An entity can be referenced either by EID or by a
      ; LookupRef, which is a unique attribute-value pair expressed as a vector.
      james-map   (td/entity-map (live-db) james-eid)                       ; lookup by EID
      james-map2  (td/entity-map (live-db) [:person/name "James Bond"] )    ; lookup by LookupRef
]
  (is (= james-map james-map2
         {:person/name "James Bond" :location "London" :weapon/type #{:weapon/wit :weapon/gun} } ))