v0.10.0 Entity selection retrieval and manipulation
Molecule now allows retrieving attribute values of selected entities:
val List(e1, e2, e3) = Ns.int.insert(1, 2, 3).eids
// Use selected entity ids to access attributes of those entities
Ns(e1, e2).int.get === List(1, 2)
// Or use a variable with a collection of entity ids
val e23 = Seq(e2, e3)
Ns(e23).int.get === List(2, 3)
Likewise we can update attribute values of selected entities (group editing):
val List(a, b, c) = Ns.str.int insert List(("a", 1), ("b", 2), ("c", 3)) eids
// Apply value to attribute of multiple entities
Ns(a, b).int(4).update
Ns.str.int.get.sorted === List(("a", 4), ("b", 4), ("c", 3))
See more examples here and here.
Datomic encourages multi-step queries where you find some entities ids with one query and then pass those ids on as input to the following query. Since we don't have the cost of round-trips to a database server, this is a powerful technique that Molecule now supports with ease.