Packages

  • package root

    Documentation/API for the Molecule library - a meta DSL for the Datomic database.

    Manual | scalamolecule.org | Github | Forum

    Definition Classes
    root
  • package molecule

    Molecule library - a Scala meta-DSL for the Datomic database.

    Molecule library - a Scala meta-DSL for the Datomic database.

    See api package for various api imports to start using Molecule.

    Sub-packages

    api Molecule API.
    ast Internal Molecule ASTs.
    boilerplate Internal interfaces for auto-generated DSL boilerplate code.
    composition    Builder methods to compose molecules.
    exceptions Exceptions thrown by Molecule.
    expression Attribute expressions and operations.
    facade Molecule facades to Datomic.
    factory Implicit macro methods `m` to instantiate molecules from custom DSL molecule constructs.
    input Input molecules awaiting input.
    macros Internal macros generating molecule code from custom DSL molecule constructs.
    generic Interfaces to generic information about datoms and Datomic database.
    ops Internal operational helpers for transforming DSL to molecule.
    schema Schema definition DSL.
    transform Internal transformers from DSL to Model/Query/Transaction.
    util Internal Java database functions for Datomic.

    Definition Classes
    root
  • package input

    Input molecules awaiting input.

    Input molecules awaiting input.

    Input molecules are molecules that awaits one or more inputs at runtime. When input value is applied, the input molecule is resolved and a standard molecule is returned that we can then call actions on.

    Input molecule queries are cached by Datomic. So there is a runtime performance gain in using input molecules. Furthermore, input molecules are a good fit for re-use for queries where only a few parameters change.

    Input molecules can await 1, 2 or 3 inputs and are constructed by applying the ? marker to attributes. If one marker is applied, we get a InputMolecule_1, 2 inputs creates an InputMolecule_2 and 3 an InputMolecule_3.

    The three input molecule interfaces come in arity-versions corresponding to the number of non-?-marked attributes in the input molecule. Let's see a simple example:

    // Sample data
    Person.name.age insert List(("Ben", 42), ("Liz", 34))
    
    // Input molecule created at compile time. Awaits a name of type String
    val ageOfPersons: InputMolecule_1.InputMolecule_1_01[String, Int] = m(Person.name_(?).age)
    
    // Resolved molecule. "Ben" input is matched against name attribute
    val ageOfPersonsNamedBen: Molecule.Molecule01[Int] = ageOfPersons.apply("Ben")
    
    // Calling action on resolved molecule.
    // (Only age is returned since name was marked as tacit with the underscore notation)
    ageOfPersonsNamedBen.get === List(42)
    
    // Or we can re-use the input molecule straight away
    ageOfPersons("Liz").get === List(34)
    Definition Classes
    molecule
  • package exception
    Definition Classes
    input
  • InputMolecule
  • InputMolecule_1
  • InputMolecule_2
  • InputMolecule_3

trait InputMolecule_1[I1] extends InputMolecule

Shared interfaces of input molecules awaiting 1 input.

// Sample data set
Person.name.age insert List(
  ("Joe", 42),
  ("Liz", 34)
)

// Input molecule awaiting 1 input for `name`
val ageOfPersons = m(Person.name_(?).age)

// Resolve input molecule with name input in various ways
ageOfPersons("Joe").get === List(42)
ageOfPersons("Joe", "Liz").get === List(42, 34)
ageOfPersons("Joe" or "Liz").get === List(42, 34)
ageOfPersons(Seq("Joe", "Liz")).get === List(42, 34)
I1

Type of input matching attribute with ? marker

Source
InputMolecule_1.scala
See also

molecule.input.InputMolecule | Manual

Linear Supertypes
Type Hierarchy
Ordering
  1. Grouped
  2. Alphabetic
  3. By Inheritance
Inherited
  1. InputMolecule_1
  2. InputMolecule
  3. MoleculeBase
  4. AnyRef
  5. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Abstract Value Members

  1. abstract val _model: Model

    Internal Model representation of molecule.

    Internal Model representation of molecule.

    Molecule transforms custom boilerplate DSL constructs to Datomic queries in 3 steps:

    Custom DSL molecule --> Model --> Query --> Datomic query string

    Definition Classes
    MoleculeBase
  2. abstract val _nestedQuery: Option[Query]

    Internal optional Query representation of nested molecule with added entity search for each level.

    Internal optional Query representation of nested molecule with added entity search for each level.

    Molecule transforms custom boilerplate DSL constructs to Datomic queries in 3 steps:

    Custom DSL molecule --> Model --> Query --> Datomic query string

    Definition Classes
    MoleculeBase
  3. abstract val _query: Query

    Internal Query representation of molecule.

    Internal Query representation of molecule.

    Molecule transforms custom boilerplate DSL constructs to Datomic queries in 3 steps:

    Custom DSL molecule --> Model --> Query --> Datomic query string

    Definition Classes
    MoleculeBase
  4. abstract val _rawNestedQuery: Option[Query]

    Internal un-optimized optional Query representation of nested molecule with added entity search for each level.

    Internal un-optimized optional Query representation of nested molecule with added entity search for each level.

    Molecule transforms custom boilerplate DSL constructs to Datomic queries in 3 steps:

    Custom DSL molecule --> Model --> Query --> Datomic query string

    Definition Classes
    MoleculeBase
  5. abstract val _rawQuery: Query

    Internal un-optimized Query representation molecule.

    Internal un-optimized Query representation molecule.

    Molecule transforms custom boilerplate DSL constructs to Datomic queries in 3 steps:

    Custom DSL molecule --> Model --> Query --> Datomic query string

    Definition Classes
    MoleculeBase
  6. abstract def apply(args: Seq[I1])(implicit conn: Conn): MoleculeBase

    Apply Seq of input values with OR semantics to resolve input molecule.

    Apply Seq of input values with OR semantics to resolve input molecule.

    Resolve input molecule by applying a Set of values that the attribute is expected to have (OR semantics).

    // Input molecule awaiting name input
    val ageOfPersons = Person.name_(?).age
    
    // Apply Seq of one or more input value(s)
    ageOfPersons.apply(Seq("Ben", "Liz"))
    
    // Same as
    ageOfPersons(Set("Ben", "Liz"))
    ageOfPersons("Ben" or "Liz")
    ageOfPersons("Ben", "Liz")

    Querying the resolved molecule will match all entities having name set to the value(s) applied.

    returns

    Resolved molecule that can be queried

    Note

    Only distinct values are matched.

  7. abstract def apply(or: Or[I1])(implicit conn: Conn): MoleculeBase

    Apply OR expression of input values to resolve input molecule.

    Apply OR expression of input values to resolve input molecule.

    Input value type matches attribute having ? marker.

    // Input molecule awaiting name input
    val ageOfPersons = Person.name_(?).age
    
    // Apply OR expression of two or more input values
    ageOfPersons.apply("Ben" or "Liz") // (one or more input values...)
    
    // Same as
    ageOfPersons("Ben", "Liz")
    ageOfPersons(Seq("Ben", "Liz"))
    ageOfPersons(Set("Ben", "Liz"))

    Querying the resolved molecule will match all entities having name set to the values applied.

    returns

    Resolved molecule that can be queried

    Note

    Only distinct values are matched.

  8. abstract def apply(arg: I1, arg2: I1, moreArgs: I1*)(implicit conn: Conn): MoleculeBase

    Apply one or more input values to resolve input molecule.

    Apply one or more input values to resolve input molecule.

    // Input molecule awaiting name input
    val ageOfPersons = Person.name_(?).age
    
    // Apply one or more input value(s)
    ageOfPersons.apply("Ben", "Liz") // (one or more input values...)
    
    // Same as
    ageOfPersons("Ben" or "Liz")
    ageOfPersons(Seq("Ben", "Liz"))
    ageOfPersons(Set("Ben", "Liz"))

    Querying the resolved molecule will match all entities having name set to the value(s) applied.

    returns

    Resolved molecule that can be queried

    Note

    Only distinct values are matched.

  9. abstract def apply(arg: I1)(implicit conn: Conn): MoleculeBase

    Apply one or more input values to resolve input molecule.

    Apply one or more input values to resolve input molecule.

    // Input molecule awaiting name input
    val ageOfPersons = Person.name_(?).age
    
    // Apply one or more input value(s)
    ageOfPersons.apply("Ben", "Liz") // (one or more input values...)
    
    // Same as
    ageOfPersons("Ben" or "Liz")
    ageOfPersons(Seq("Ben", "Liz"))
    ageOfPersons(Set("Ben", "Liz"))

    Querying the resolved molecule will match all entities having name set to the value(s) applied.

    returns

    Resolved molecule that can be queried

    Note

    Only distinct values are matched.

Concrete Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. def addNilClause(clauses: Seq[Clause], e: Var, kw: KW, v0: Var): Seq[Clause]
    Attributes
    protected
    Definition Classes
    InputMolecule
  5. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  6. def bindValues(query: Query, inputs0: Seq[I1]): Query
    Attributes
    protected
  7. def cardinality(nsFull: String, attr: String): Int
    Attributes
    protected
    Definition Classes
    InputMolecule
  8. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native()
  9. def dataClause(e: String, kw: KW, enumPrefix: Option[String], arg: Any, i: Int): Seq[Clause]
    Attributes
    protected
    Definition Classes
    InputMolecule
  10. def deepNil(args: Seq[Any]): Boolean
    Attributes
    protected
    Definition Classes
    InputMolecule
  11. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  12. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  13. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable])
  14. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  15. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  16. def isExpression(nsFull: String, attr: String): Boolean
    Attributes
    protected
    Definition Classes
    InputMolecule
  17. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  18. def isTacit(nsFull: String, attr: String): Boolean
    Attributes
    protected
    Definition Classes
    InputMolecule
  19. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  20. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  21. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  22. def pre[T](enumPrefix: Option[String], arg: T): Any
    Attributes
    protected
    Definition Classes
    InputMolecule
  23. def resolveInput[T](query: Query, ph: Placeholder, inputs: Seq[T], ruleName: String = "rule1", unifyRule: Boolean = false): Query
    Attributes
    protected
    Definition Classes
    InputMolecule
  24. def resolveOr[I1](or: Or[I1]): Seq[I1]
    Attributes
    protected
    Definition Classes
    InputMolecule
  25. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  26. def toString(): String
    Definition Classes
    AnyRef → Any
  27. def valueClauses[TT](e: String, kw: KW, enumPrefix: Option[String], args: TT): Seq[Clause]
    Attributes
    protected
    Definition Classes
    InputMolecule
  28. def varsAndPrefixes(query: Query): Seq[(Var, String)]
    Attributes
    protected
    Definition Classes
    InputMolecule
  29. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  30. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  31. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()

Inherited from InputMolecule

Inherited from MoleculeBase

Inherited from AnyRef

Inherited from Any

internal

Ungrouped