Attributes

Examples from the sub pages:


Attribute basics, return types, arity, cardinality (tests)

val persons: Iterable[(String, Int)] = Person.name.age.get


Mandatory/Tacet/Optional attributes (tests)

Person.name.age.get  // all required values              ("mandatory value")
Person.name.age_.get // age is required but not returned ("tacit value")
Person.name.age$.get // optional age returned            ("optional value")


Map attributes - mapped attribute values (tests)

Person.id.name.get.head === (
  1, 
  Map(
    "en" -> "Dmitri Shostakovich",
    "de" -> "Dmitri Schostakowitsch",
    "fr" -> "Dmitri Chostakovitch",
    "es" -> "Dmitri Shostakóvich"
  )
)


Expressions - filter attribute values with expressions (tests)

Person.age(42)                  // equality
Person.name.contains("John")    // fulltext search
Person.age.!=(42)               // negation
Person.age.<(42)                // comparison
Person.age(nil)                 // nil (null)
Person.name("John" or "Jonas")  // OR-logic


Aggregates - aggregate attribute values (tests)

Person.age(min) 
Person.age(max) 
// rand, sample, count, countDistinct, sum, avg, median, variance, stddev


Parameterize - re-use molecules and let Datomic cache queries and optimize performance (tests)

val person = Person.name(?).age(?)

// Re-use `person`
val Johan  = person("John", 33).get.head
val Lisa   = person("Lisa", 27).get.head