Packages

  • package root

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

    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.

    Definition Classes
    root
  • package core
    Definition Classes
    molecule
  • package api
    Definition Classes
    core
  • package exception
  • GetJson
  • GetObjs
  • Keywords
  • Molecule
  • Molecule_0
  • Molecule_1
  • Molecule_2
  • Molecule_3
  • OptionalMapOps
  • TxBundles
  • TxFunctions
  • package ast

    Internal Molecule ASTs.

    Internal Molecule ASTs.

    Definition Classes
    core
  • package composition

    Methods to build transaction, composite and nested molecules.

    Methods to build transaction, composite and nested molecules.

    Definition Classes
    core
  • package data

    Data model DSL and API.

    Data model DSL and API.

    Definition Classes
    core
  • package dsl

    Internal interfaces for auto-generated DSL boilerplate code.

    Internal interfaces for auto-generated DSL boilerplate code.

    Interfaces to the generated schema-defined DSL boilerplate code that the sbt-plugin generates when doing a sbt-compile. Molecule macros can then type-safely deduct the type structure of composed molecules.

    Definition Classes
    core
  • package exceptions

    Exceptions thrown by Molecule.

    Exceptions thrown by Molecule.

    Definition Classes
    core
  • package expression

    Attribute expressions and operations.

    Attribute expressions and operations.

    Refine attribute matches with various attribute expressions:

    Person.age(42)                           // equality
    Person.name.contains("John")             // fulltext search
    Person.age.!=(42)                        // negation (or `not`)
    Person.age.<(42)                         // comparison (< > <= >=)
    Person.name("John" or "Jonas")           // OR-logic
    Person.age()                             // apply empty value to retract value(s) in updates
    Person.hobbies.assert("golf")            // add value(s) to card-many attributes
    Person.hobbies.retract("golf")           // retract value(s) of card-many attributes
    Person.hobbies.replace("golf", "diving") // replace value(s) of card-many attributes
    Person.tags.k("en")                      // match values of map attributes by key
    Person.age(Nil)                          // match non-asserted datoms (null)
    Person.name(?)                           // initiate input molecules awaiting input at runtime
    Person.name(unify)                       // Unify attributes in self-joins

    Apply aggregate keywords to aggregate attribute value(s):

    // Aggregates on any attribute type
    Person.age(count).get.map(_.head ==> 3)         // count of asserted `age` attribute values
    Person.age(countDistinct).get.map(_.head ==> 3) // count of asserted distinct `age` attribute values
    Person.age(max).get.map(_.head ==> 38)          // maximum `age` value (using `compare`)
    Person.age(min).get.map(_.head ==> 5)           // maximum `age` value (using `compare`)
    Person.age(rand).get.map(_.head ==> 25)         // single random `age` value
    Person.age(sample).get.map(_.head ==> 27)       // single sample `age` value (when single value, same as random)
    
    // Aggregates on any attribute type, returning multiple values
    Person.age(distinct).get.map(_.head ==> Vector(5, 7, 38)) // distinct `age` values
    Person.age(max(2)).get.map(_.head ==> Vector(38, 7))      // 2 maximum `age` values
    Person.age(min(2)).get.map(_.head ==> Vector(5, 7))       // 2 minimum `age` values
    Person.age(rand(2)).get.map(_.head ==> Stream(5, ?))      // 2 random `age` values (values can re-occur)
    Person.age(sample(2)).get.map(_.head ==> Vector(7, 38))   // 2 sample `age` values
    
    // Aggregates on number attributes
    Person.age(sum).get.map(_.head ==> 50)                  // sum of all `age` numbers
    Person.age(avg).get.map(_.head ==> 16.66666667)         // average of all `age` numbers
    Person.age(median).get.map(_.head ==> 7)                // median of all `age` numbers
    Person.age(stddev).get.map(_.head ==> 15.107025591499)  // standard deviation of all `age` numbers
    Person.age(variance).get.map(_.head ==> 228.2222222222) // variance of all `age` numbers
    Definition Classes
    core
  • package factory

    Factory methods m to instantiate molecules from custom DSL molecule constructs.

    Factory methods m to instantiate molecules from custom DSL molecule constructs.

    Definition Classes
    core
  • package generic
    Definition Classes
    core
  • package macros
    Definition Classes
    core
  • package marshalling
    Definition Classes
    core
  • package ops
    Definition Classes
    core
  • package transform
    Definition Classes
    core
  • package util

    Internal database functions for Datomic.

    Internal database functions for Datomic.

    Definition Classes
    core

package api

Ordering
  1. Alphabetic
Visibility
  1. Public
  2. All

Type Members

  1. trait GetJson[Obj, Tpl] extends JavaUtil

    Data getter methods on molecules that return data as a Json String.

    Data getter methods on molecules that return data as a Json String.

    Attributes names are used as Json field names.

  2. trait GetObjs[Obj, Tpl] extends AnyRef

    Data getter methods on molecules that return data as Lists of objects with attribute properties.

    Data getter methods on molecules that return data as Lists of objects with attribute properties.

    Attributes names are used as object property names.

  3. trait Molecule extends AnyRef

    Base Molecule interface.

  4. abstract class Molecule_0[Obj, Tpl] extends Marshalling[Obj, Tpl] with CastTypes with CastAggr with CastOptNested with JsonTypes with JsonAggr with JsonOptNested with GetTpls[Obj, Tpl] with GetObjs[Obj, Tpl] with GetJson[Obj, Tpl] with ShowInspect[Obj, Tpl] with Helpers

    Core molecule interface defining actions that can be called on molecules.

    Core molecule interface defining actions that can be called on molecules.

    Groups of interfaces:

    get Get molecule data.
    getAsOf Get molecule data asOf point in time.
    getSince Get molecule data since point in time.
    getWith Get molecule data with given data set.
    getHistory Get molecule data from history of database.
    save Save molecule with applied data.
    insert Insert multiple rows of data matching a molecule.
    update Update molecule with applied data.
    tx Molecule transaction data (input to `getWith`).
    inspect get Inspect calling get method on molecule.
    inspect operation     Inspect calling save/insert/update method on molecule.

    Tpl

    Type of molecule (tuple of its attribute types)

    See also

    For retract ("delete") methods, see molecule.datomic.base.api.EntityOps and molecule.datomic.base.api.DatomicEntity.

  5. abstract class Molecule_1[Obj, I1] extends InputMolecule

    Shared interfaces of input molecules awaiting 1 input.

    Shared interfaces of input molecules awaiting 1 input.

    // Input molecule awaiting 1 input for `name`
    val ageOfPersons = m(Person.name_(?).age)
    for {
      // Sample data set
      _ <- Person.name.age insert List(
        ("Joe", 42),
        ("Liz", 34)
      )
    
      // Resolve input molecule with name input in various ways
      _ <- ageOfPersons("Joe").get.map(_ ==> List(42))
      _ <- ageOfPersons("Joe", "Liz").get.map(_ ==> List(42, 34))
      _ <- ageOfPersons("Joe" or "Liz").get.map(_ ==> List(42, 34))
      _ <- ageOfPersons(Seq("Joe", "Liz")).get.map(_ ==> List(42, 34))
    } yield ()
    I1

    Type of input matching attribute with ? marker

  6. abstract class Molecule_2[Obj, I1, I2] extends InputMolecule

    Shared interfaces of input molecules awaiting 2 inputs.

    Shared interfaces of input molecules awaiting 2 inputs.

    // Input molecule awaiting 2 inputs for `profession` and `age`
    val profAge = m(Person.name.profession_(?).age_(?))
    for {
      // Sample data set
      _ <- Person.name.profession.age insert List(
        ("Ann", "doctor", 37),
        ("Ben", "teacher", 37),
        ("Joe", "teacher", 32),
        ("Liz", "teacher", 28)
      )
    
      // A. Pairs of input .................................
    
      // One pair as params
      _ <- profAge("doctor", 37).get.map(_ ==> List("Ann"))
    
      // One or more pairs
      _ <- profAge(("doctor", 37)).get.map(_ ==> List("Ann"))
      _ <- profAge(("doctor", 37), ("teacher", 37)).get.map(_.sorted ==> List("Ann", "Ben"))
    
      // One or more logical pairs
      // [pair-expression] or [pair-expression] or ...
      _ <- profAge(("doctor" and 37) or ("teacher" and 32)).get.map(_.sorted ==> List("Ann", "Joe"))
      _ <- profAge(Seq(("doctor", 37), ("teacher", 37))).get.map(_.sorted ==> List("Ann", "Ben"))
    
      // List of pairs
      _ <- profAge(Seq(("doctor", 37))).get.map(_ ==> List("Ann"))
    
    
      // B. 2 groups of input, one for each input attribute .................................
    
      // Two expressions
      // [profession-expression] and [age-expression]
      _ <- profAge("doctor" and 37).get.map(_ ==> List("Ann"))
      _ <- profAge(("doctor" or "teacher") and 37).get.map(_.sorted ==> List("Ann", "Ben"))
      _ <- profAge(("doctor" or "teacher") and (32 or 28)).get.map(_.sorted ==> List("Joe", "Liz"))
    
      // Two Lists
      _ <- profAge(Seq("doctor"), Seq(37)).get.map(_ ==> List("Ann"))
      _ <- profAge(Seq("doctor", "teacher"), Seq(37)).get.map(_.sorted ==> List("Ann", "Ben"))
      _ <- profAge(Seq("teacher"), Seq(37, 32)).get.map(_.sorted ==> List("Ben", "Joe"))
      _ <- profAge(Seq("doctor", "teacher"), Seq(37, 32)).get.map(_.sorted ==> List("Ann", "Ben", "Joe"))
    } yield ()
    I1

    Type of input matching first attribute with ? marker (profession: String)

    I2

    Type of input matching second attribute with ? marker (age: Int)

  7. abstract class Molecule_3[Obj, I1, I2, I3] extends InputMolecule

    Shared interfaces of input molecules awaiting 3 inputs.

    Shared interfaces of input molecules awaiting 3 inputs.

    // Input molecule awaiting 3 inputs for `profession`, `age` and `score`
    val profAgeScore = m(Person.name.profession_(?).age_(?).score_(?))
    for {
      // Sample data set
      Person.name.profession.age.score insert List(
        ("Ann", "doctor", 37, 1.0),
        ("Ben", "teacher", 37, 1.0),
        ("Joe", "teacher", 32, 1.0),
        ("Liz", "teacher", 28, 2.0)
      )
    
      // A. Triples of input .................................
    
      // One triple as params
      _ <- profAgeScore.apply("doctor", 37, 1.0).get.map(_ ==> List("Ann"))
    
      // One or more triples
      _ <- profAgeScore.apply(("doctor", 37, 1.0)).get.map(_ ==> List("Ann"))
      _ <- profAgeScore.apply(("doctor", 37, 1.0), ("teacher", 37, 1.0)).get.map(_.sorted ==> List("Ann", "Ben"))
    
      // One or more logical triples
      // [triple-expression] or [triple-expression] or ...
      _ <- profAgeScore.apply(("doctor" and 37 and 1.0) or ("teacher" and 32 and 1.0)).get.map(_.sorted ==> List("Ann", "Joe"))
    
      // List of triples
      _ <- profAgeScore.apply(Seq(("doctor", 37, 1.0))).get.map(_ ==> List("Ann"))
      _ <- profAgeScore.apply(Seq(("doctor", 37, 1.0), ("teacher", 37, 1.0))).get.map(_.sorted ==> List("Ann", "Ben"))
    
    
      // B. 3 groups of input, one for each input attribute .................................
    
      // Three expressions
      // [profession-expression] and [age-expression] and [score-expression]
      _ <- profAgeScore.apply("doctor" and 37 and 1.0).get.map(_ ==> List("Ann"))
      _ <- profAgeScore.apply(("doctor" or "teacher") and 37 and 1.0).get.map(_.sorted ==> List("Ann", "Ben"))
      _ <- profAgeScore.apply(("doctor" or "teacher") and (37 or 32) and 1.0).get.map(_.sorted ==> List("Ann", "Ben", "Joe"))
      _ <- profAgeScore.apply(("doctor" or "teacher") and (37 or 32) and (1.0 or 2.0)).get.map(_.sorted ==> List("Ann", "Ben", "Joe"))
    
      // Three lists
      _ <- profAgeScore.apply(Seq("doctor"), Seq(37), Seq(1.0)).get.map(_ ==> List("Ann"))
      _ <- profAgeScore.apply(Seq("doctor", "teacher"), Seq(37), Seq(1.0)).get.map(_.sorted ==> List("Ann", "Ben"))
    } yield ()
    I1

    Type of input matching first attribute with ? marker (profession: String)

    I2

    Type of input matching second attribute with ? marker (age: Int)

    I3

    Type of input matching third attribute with ? marker (score: Double)

  8. trait TxBundles extends Helpers with BooPicklers
  9. trait TxFunctions extends AnyRef

    Transactional methods for bundled transactions and tx functions

Value Members

  1. object Keywords extends Keywords
  2. object Molecule_0

    Arity 1-22 molecule implementation interfaces.

  3. object Molecule_1

    Implementations of input molecules awaiting 1 input, output arity 1-22

  4. object Molecule_2

    Implementations of input molecules awaiting 2 inputs, output arity 1-22

  5. object Molecule_3

    Implementations of input molecules awaiting 3 inputs, output arity 1-22

  6. object OptionalMapOps extends OptionalMapOps

    Optional implicit operations for optional Map attributes

    Optional implicit operations for optional Map attributes

    Is not imported in the default Molecule api imports since they are rather specialized. If needed, they can be made available with the following aditional import:

    import molecule.api.optionalMapOps._
    import molecule.datomic.api._ // Standard api import with any arity

    Since this is a rather specialized

  7. object TxFunctions extends Helpers with JavaUtil

Ungrouped