Fork me on GitHub
#datascript
<
2017-03-03
>
qqq04:03:23

is there any reason datascript tends to use attributes o the form: :foo/name :dog/age :student/gender instead of "name", "age", or "gender" ?

bbss05:03:33

That's not really related to datascript, it's generally recommended to switch to namespaced keywords.

bbss05:03:45

But it does fit the "entity" concept nicely imo.

Niki05:03:44

Initially it was recommended by Datomic because it leads to better index locality

qqq05:03:30

oh right, if I have :student/name and :computer/name and :employee/name

Niki05:03:38

E.g. person names would not mix with goods names

qqq05:03:47

then when I lolk up :computer/name, it's not returning stuff with :employee/name or :student/name

Niki05:03:01

Turned out it leads to better code as well

Niki05:03:45

You see a piece of code anywhere and understand immediately with what it works: persons, goods, etc

Niki05:03:31

Also much easier to search and replace if you need to rename/refactor/adjust something

Niki05:03:43

It's impossible to search for just "name", too many unnecessary stuff will pop up as well

qqq05:03:58

@tonsky: I completely agree with your logic. Why does this logic not also apply to vec2? i.e. {:x 20 :y 40} vs {:vec2/x 20 :vec2/y 40} people tend ot use the former more than the latter

Niki06:03:52

Because x and y are not domain names

jrychter09:03:49

Is it still the case that I can't delete non-existing refs? I am looking at the code for avoiding this and I'd really like to get rid of it. Apart from seeming unnecessary, it slows down my app considerably, because when doing mass-deletes I have to first find all existing entities, just to avoid deleting non-existing ones.

misha10:03:38

(let [c (ds/create-conn)]
  (ds/transact! c [[:db.fn/retractEntity 100]]))
=>
{:db-before {},
 :db-after {},
 :tx-data [],
 :tempids {:db/current-tx 536870913},
 :tx-meta nil}

misha10:03:44

(let [c (ds/create-conn)]
  (ds/transact! c [[:db/retract 100 :foo :bar]]))
=>
{:db-before {},
 :db-after {},
 :tx-data [],
 :tempids {:db/current-tx 536870913},
 :tx-meta nil}
[datascript "0.15.5"]

jrychter10:03:58

Hmm. It seems it is possible now — I wonder when that changed. Digging into my code now.

Niki15:03:20

what do you mean by deleting non-existing entities?