<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Datomic Knowledgebase - Recent questions tagged lookup refs</title>
<link>https://ask.datomic.com/index.php/tag/lookup+refs</link>
<description>Powered by Question2Answer</description>
<item>
<title>Can a tuple value be added when one of the parts of the tuple is an lookup-ref?</title>
<link>https://ask.datomic.com/index.php/891/can-tuple-value-added-when-one-the-parts-the-tuple-lookup-ref</link>
<description>&lt;p&gt;I'm wanting to use a lookup ref instead of an entity id (:db-id) when specifying the value for a tuple of attributes where one of the attributes is of type :db.type/ref. Is this possible? I've looked over the Datomic Cloud grammar on transactions and I don't see how to specify a tuple value at all (maybe I'm missing something). I've tried what I thought would be the obvious way to do it and this doesn't work. Here's what I have...&lt;/p&gt;
&lt;p&gt;Truncated schema:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;{:db/ident       :molecule/legacy-id
 :db/unique      :db.unique/identity
 :db/valueType   :db.type/long
 :db/cardinality :db.cardinality/one
 :db/doc         &quot;The Molecule/Complex id from the ProcessDB Oracle database.&quot;}
{:db/ident       :molecule-part/number
 :db/valueType   :db.type/long
 :db/cardinality :db.cardinality/one
 :db/doc         &quot;The number of molecules for this molecule. The entity with this attribute may be reused and is
 not unique for a particular complex so do not change this number. Instead, check for another existing entity
 or create one.&quot;}
{:db/ident       :molecule-part/molecule
 :db/valueType   :db.type/ref
 :db/cardinality :db.cardinality/one
 :db/doc         &quot;The molecule this part refers to. The entity with this attribute may be reused and is
 not unique for a particular complex.&quot;}
{:db/ident       :molecule-part/number+molecule
 :db/unique      :db.unique/identity
 :db/valueType   :db.type/tuple
 :db/tupleAttrs  [:molecule-part/number :molecule-part/molecule]
 :db/cardinality :db.cardinality/one
 :db/doc         &quot;The number and molecule that collectively form the unique identity of this entity.&quot;}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Then I try to add a molecule part using&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(d/transact (db/get-connection) {:tx-data [{:molecule-part/molecule [:molecule/legacy-id 717] :molecule-part/number 1 :molecule-part/number+molecule [1 [:molecule/legacy-id 717]]}]})
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And get the following error&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;:db.error/invalid-tuple-value Invalid tuple value
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If I replace &quot;[:molecule/legacy-id 717]&quot; with the entity id (:db/id) for that molecule then it works. But I don't want to use the entity id... I want to use the lookup ref, because what I have is the :molecule/legacy-id. I don't want to have to do a query to resolve this before doing a transaction to add the :molecule-part.&lt;/p&gt;
</description>
<category>Cloud</category>
<guid isPermaLink="true">https://ask.datomic.com/index.php/891/can-tuple-value-added-when-one-the-parts-the-tuple-lookup-ref</guid>
<pubDate>Thu, 20 Apr 2023 20:09:32 +0000</pubDate>
</item>
<item>
<title>Is using entid function to resolve lookup refs a supported behaviour?</title>
<link>https://ask.datomic.com/index.php/721/using-entid-function-resolve-lookup-refs-supported-behaviour</link>
<description>&lt;p&gt;I'm using &lt;code&gt;datomic.api/entid&lt;/code&gt; to resolve a lookup ref to an entity ID, like&lt;br&gt;
&lt;code&gt;$ (entid db [:user/id &quot;test@test.com&quot;])
17592186045432&lt;/code&gt;&lt;br&gt;
This works fine, but a colleague pointed out this is not a documented behaviour.&lt;br&gt;
&amp;gt;Usage: (entid db ident)&lt;br&gt;
&amp;gt;Returns the entity id associated with a symbolic keyword, or the id&lt;br&gt;
itself if passed.&lt;/p&gt;
&lt;p&gt;Is this a gap in documentation, or is this behaviour accidental and not recommended to rely on?&lt;/p&gt;
</description>
<category>On-Prem</category>
<guid isPermaLink="true">https://ask.datomic.com/index.php/721/using-entid-function-resolve-lookup-refs-supported-behaviour</guid>
<pubDate>Wed, 08 Jun 2022 13:30:29 +0000</pubDate>
</item>
</channel>
</rss>