Closed frankiesardo closed 10 years ago
Yeah, I forgot about that case :( Maybe we should go with something like Datomic’s tempids
or deduce value type from schema. Will think of something for the next version
Have you given this any more thought? It seems like specifying the value type in the schema has the advantage that you could return referenced entities in the d/entity function, similar to Datomic. So, in frankiesardo's example, you could do
(def e (d/entity db 1))
(get-in e [:components 0 :name]) ; => "foo"
Of course, d/entity would have to be rewritten to support that. But it seems like for that to be possible, you would want the type to be in the schema.
I’ll probably go with the schema, and leave negative ids as they works right now, without tempid
wrapper. Entity
to follow references is a little bit harder because there may be cycles so we need lazy entities for this to work properly. It’s on the roadmap, but not on the closest one.
Check out test.datascript/test-resolve-eid-refs
for usage example
I apologise if it's just me, but by reading the docs it's not very clear how to reference other entities inside datascript.
How do I reference the generated ids
10
and11
inside thecomponents
vector?