Ahoy maties!
Is it possible to explain like I'm Newb how i can write to datascript with cross-erefrences to other keywords?
I'm wanting to save appointment data and that looks like
client
service-provider
staff-member
and the three coming together on a Date is an appt. Something like that. When I want to add-appointment to my datascript db, I want to write references to the service-provider/id and to the staff-member/id etc
But I'm having trouble.
Thanks for your help so much, finally got it working. Am using something along the lines of [:client/id (uuid client-string)] because of how am storing uuids
Sounds like each appointment is an entity and has at least 4 attributes, one for the date and the others are references to other entities (a client, a service provider, and a staff member). Does that sound about right?
Yes, exactly. And then referenccing the other entities, I'm running into trouble getting them to transact, or getting them to show up. I am fairly confident the schema supports what I'm writing, but I'm not clear on if I should have the full UUID or the [:user/id #uuid] pattern
This is one way to write a transaction that creates a new appointment with the relevant references. If the client/provider/staff entities have unique attributes you can use those in place of providing the database ID
(defn create-appointment [date client-id provider-id staff-id]
[[:db/add -1 :appointment/date date]
[:db/add -1 :appointment/client client-id]
[:db/add -1 :appointment/provider provider-id]
[:db/add -1 :appointment/staff staff-id]])
And this would be the relevant schema
(def schema
{:appointment/client {:db/valueType :db.type/ref}
:appointment/provider {:db/valueType :db.type/ref}
:appointment/staff {:db/valueType :db.type/ref}})Are you getting an error on transaction or just not seeing what you expect when you make a query?
Right now I see 'Tempids used only as value in transaction: ("15589d57-a5eb-4d64-8e98-783c82a8cd2e")' even though the schema supports them with the :db.type/ref
What does your transaction look like? If you want to use a UUID you'll need to make sure its a unique attribute and to use a look up ref like [:db/add -1 :appointment/client [:client/uuid "15589d57-a5eb-4d64-8e98-783c82a8cd2e"]]