Closed
Description
Datascript 0.18.7
I have the following schema . Events can have multiple contacts associated with them but I want contacts to remain as truly independent entities
;;=========CONTACT===========
:contact/name {:db/doc "First and Lastname of the contact"
:db/unique :db.unique/identity}
:contact/firstname {:db/cardinality :db.cardinality/one
:db/doc "Contact firstname"}
:contact/lastname {:db/cardinality :db.cardinality/one
:db/doc "Contact lastname"}
:contact/type {:db/cardinality :db.cardinality/one
:db/doc "Contact type - ref to contact type lookup"}
:contact/mobilephone {:db/doc "Contact Mobile Phone number"}
:event/contacts {:db/doc "Event Contact - ref to Contact"
:db/isComponent true
:db/cardinality :db.cardinality/many
:db/valueType :db.type/ref
}
I then load it up with data and it looks something like this
{:event/endtime #inst "2019-10-12T00:30:00.000-00:00",
:event/desc "Corp Earnings Event Baltimore, MD",
:event/contacts
[{:db/id 63, :contact/name "Janet Lansdale"}
{:db/id 64, :contact/name "Nina Simone"}],
:event/starttime #inst "2019-10-11T16:31:00.000-00:00",
:db/id 62,
:event/status [:lookup/name "QUOTING"]}
When I want to dissoc one of these contacts, I run a transact with this same data structure but I remove one of the entries ..eg. Nina Simone as shown below
{:event/endtime #inst "2019-10-12T00:30:00.000-00:00",
:event/desc "Corp Earnings Event Baltimore, MD",
:event/contacts
[{:db/id 63, :contact/name "Janet Lansdale"}],
:event/starttime #inst "2019-10-11T16:31:00.000-00:00",
:db/id 62,
:event/status [:lookup/name "QUOTING"]}
or to remove them completely I try
{:event/endtime #inst "2019-10-12T00:30:00.000-00:00",
:event/desc "Corp Earnings Event Baltimore, MD",
:event/contacts [],
:event/starttime #inst "2019-10-11T16:31:00.000-00:00",
:db/id 62,
:event/status [:lookup/name "QUOTING"]}
but submitting these transactions does not remove them.
Question: How do you run a transaction that will dissoc the contacts from the events but NOT delete them.
Interestingly, as long as I add more, there is no problem but not going the other way ?
Metadata
Metadata
Assignees
Labels
No labels