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 facade

    Molecule facades to Datomic.

    Molecule facades to Datomic.

    Facades are not trying to cover all Datomic methods but rather only interfaces relevant to Molecule.

    Definition Classes
    molecule
  • package exception
    Definition Classes
    facade
  • Conn
  • Datomic
  • TxReport

class Conn extends Helpers

Facade to Datomic Connection.

Source
Conn.scala
See also

Manual | Tests: testDbAsOf, testDbSince, testDbWith,

Linear Supertypes
Helpers, AnyRef, Any
Type Hierarchy
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Conn
  2. Helpers
  3. AnyRef
  4. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new Conn(datomicConn: Connection)

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. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. final def cast(value: Any): String
    Attributes
    protected
    Definition Classes
    Helpers
  6. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )
  7. final def date(s: String): Date
    Attributes
    protected
    Definition Classes
    Helpers
  8. val datomicConn: Connection
  9. def db: Database

    Get current test/live db.

    Get current test/live db. Test db has preference.

  10. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  11. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  12. final def f(a: Any): Any
    Attributes
    protected
    Definition Classes
    Helpers
  13. final def f2(a: Any): Any
    Attributes
    protected
    Definition Classes
    Helpers
  14. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  15. final def format(date: Date): String
    Attributes
    protected
    Definition Classes
    Helpers
  16. final def format2(date: Date): String
    Attributes
    protected
    Definition Classes
    Helpers
  17. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  18. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  19. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  20. def liveDbUsed: Boolean

    Flag to indicate if live database is used

  21. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  22. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  23. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  24. final def o(opt: Option[Any]): String
    Attributes
    protected
    Definition Classes
    Helpers
  25. def q(db: Database, query: String, inputs: Seq[Any]): List[List[AnyRef]]

    Query Datomic directly with db value and optional Scala inputs.

    Query Datomic directly with db value and optional Scala inputs.

    // Sample data
    Ns.str.int.get === List(
      ("Liz", 37),
      ("Ben", 42),
    )
    
    // Start out easily with a Datomic query from debug output
    Ns.str.int.debugGet // shows datomic query...
    
    // Paste Datomic query into `q` call and use some db value
    conn.q(conn.db,
           """[:find  ?b ?c
             | :where [?a :Ns/str ?b]
             |        [?a :Ns/int ?c]]""".stripMargin) === List(
      List("Liz", 37),
      List("Ben", 42)
    )
    
    // Modify Datomic query to see result, for instance
    // by adding input to query and applying input value
    conn.q(conn.db,
           """[:find  ?b ?c
             | :in    $ ?c
             | :where [?a :Ns/str ?b]
             |        [?a :Ns/int ?c]]""".stripMargin,
           Seq(42) // input values in list
     ) === List(
      List("Ben", 42)
    )
    db

    Any Datomic Database value (could be asOf(x) etc)

    query

    Datomic query string

    inputs

    Seq of optional input(s) to query

    returns

    List[List[AnyRef]]

  26. def q(query: String, inputs: Any*): List[List[AnyRef]]

    Query Datomic directly with optional Scala inputs.

    Query Datomic directly with optional Scala inputs.

    // Sample data
    Ns.str.int.get === List(
      ("Liz", 37),
      ("Ben", 42),
    )
    
    // Start out easily with a Datomic query from debug output
    Ns.str.int.debugGet // shows datomic query...
    
    // Paste Datomic query into `q` call
    conn.q("""[:find  ?b ?c
             | :where [?a :Ns/str ?b]
             |        [?a :Ns/int ?c]]""".stripMargin) === List(
      List("Liz", 37),
      List("Ben", 42)
    )
    
    // Modify Datomic query to see result, for instance
    // by adding input to query and applying input value
    conn.q("""[:find  ?b ?c
             | :in    $ ?c
             | :where [?a :Ns/str ?b]
             |        [?a :Ns/int ?c]]""".stripMargin, 42) === List(
      List("Ben", 42)
    )
    query

    Datomic query string

    inputs

    Optional input(s) to query

    returns

    List[List[AnyRef]]

  27. def qRaw(db: Database, query: String, inputs: Seq[Any]): Collection[List[AnyRef]]

    Query Datomic directly with db value and optional Scala inputs and get raw Java result.

    Query Datomic directly with db value and optional Scala inputs and get raw Java result.

    // Sample data
    Ns.str.int.get === List(
      ("Liz", 37),
      ("Ben", 42),
    )
    
    // Get some Datomic query from debug output
    Ns.str.int.debugGet // shows datomic query...
    
    // Paste Datomic query into `q` call and use some db value
    conn.q(conn.db,
           """[:find  ?b ?c
             | :where [?a :Ns/str ?b]
             |        [?a :Ns/int ?c]]""".stripMargin)
        .toString === """[["Liz" 37], ["Ben" 42]]"""
    
    // Modify Datomic query to see result, for instance
    // by adding input to query and applying input value
    conn.q(conn.db,
           """[:find  ?b ?c
             | :in    $ ?c
             | :where [?a :Ns/str ?b]
             |        [?a :Ns/int ?c]]""".stripMargin,
           Seq(42) // input values in list
     ).toString === """[["Ben" 42]]"""
    db

    Any Datomic Database value (could be asOf(x) etc)

    query

    Datomic query string

    inputs

    Seq of optional input(s) to query

    returns

    java.util.Collection[java.util.List[AnyRef]]

  28. def qRaw(query: String, inputs: Any*): Collection[List[AnyRef]]

    Query Datomic directly with optional Scala inputs and get raw Java result.

    Query Datomic directly with optional Scala inputs and get raw Java result.

    // Sample data
    Ns.str.int.get === List(
      ("Liz", 37),
      ("Ben", 42),
    )
    
    // Start out easily with a Datomic query from debug output
    Ns.str.int.debugGet // shows datomic query...
    
    // Paste Datomic query into `q` call
    conn.q("""[:find  ?b ?c
             | :where [?a :Ns/str ?b]
             |        [?a :Ns/int ?c]]""".stripMargin)
        .toString === """[["Liz" 37], ["Ben" 42]]"""
    
    // Modify Datomic query to see result, for instance
    // by adding input to query and applying input value
    conn.q("""[:find  ?b ?c
             | :in    $ ?c
             | :where [?a :Ns/str ?b]
             |        [?a :Ns/int ?c]]""".stripMargin, 42).toString === """[["Ben" 42]]"""
    query

    Datomic query string

    inputs

    Optional input(s) to query

    returns

    java.util.Collection[java.util.List[AnyRef]]

  29. def query(model: Model, query: Query): Collection[List[AnyRef]]

    Query Datomic with Model and Query to get raw Java data.

    Query Datomic with Model and Query to get raw Java data.

    Will transparently relegate query depending on Model to:

    - Datalog query execution - Datoms API accessing index - Log API accessing log

    Return type (tuple matching the molecule) is the same for all 3 APIs so that application code can query and access data of all molecules the same way.

    model

    Model instance

    query

    Query instance

    returns

    java.util.Collection[java.util.List[AnyRef]]

  30. final lazy val sdf: SimpleDateFormat
    Attributes
    protected
    Definition Classes
    Helpers
  31. final def seq[T](values: Seq[T]): String
    Attributes
    protected
    Definition Classes
    Helpers
  32. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  33. def testDb(db: Database): Unit

    Manually apply a database to use.

  34. def testDbAsOf(txR: TxReport): Unit

    Use test database as of transaction report.

    Use test database as of transaction report.

    txR

    Transaction report

  35. def testDbAsOf(d: Date): Unit

    Use test database as of date.

    Use test database as of date.

    d

    Date

  36. def testDbAsOf(t: Long): Unit

    Use test database as of time t.

    Use test database as of time t.

    t

    Long

  37. def testDbAsOfNow: Unit

    Use test database as of now.

  38. def testDbSince(txR: TxReport): Unit

    Use test database since transaction report.

    Use test database since transaction report.

    txR

    Transaction report

  39. def testDbSince(d: Date): Unit

    Use test database since date.

    Use test database since date.

    d

    Date

  40. def testDbSince(t: Long): Unit

    Use test database since time t.

    Use test database since time t.

    t

    Long

  41. def testDbWith(txDataJava: List[List[AnyRef]]): Unit

    Use test database with temporary raw Java transaction data.

  42. def testDbWith(txData: Seq[Seq[Statement]]*): Unit

    Use test database with temporary transaction data.

    Use test database with temporary transaction data.

    Transaction data can be supplied from any molecule:

    val benId = Person.name("Ben").save.eid
    
    // Use temporary db with given transaction data applied
    conn.testDbWith(
      Person.name("liz").getSaveTx
    )
    
    // Query using temporary database including Liz
    Person.name.get === List("Ben", "Liz")
    
    // Multiple transactions can be applied
    conn.testDbWith(
      Person.name("Joe").getSaveTx,
      benId.getRetractTx
    )
    Person.name.get === List("Liz", "Joe")
    txData

    List of List of transaction Statement's

  43. final def time(n: Int, prev: Int = 0): Unit
    Attributes
    protected
    Definition Classes
    Helpers
  44. def toString(): String
    Definition Classes
    AnyRef → Any
  45. def transact(rawTxStmts: List[AnyRef]): TxReport

    Transact edn files or other raw transaction data.

    Transact edn files or other raw transaction data.

    val data_rdr2 = new FileReader("examples/resources/seattle/seattle-data1a.dtm")
    val rawTxStmts = Util.readAll(data_rdr2).get(0).asInstanceOf[java.util.List[Object]]
    
    // transact
    val result: TxReport = conn.transact(rawTxStmts)
    rawTxStmts

    Raw transaction data, typically from edn file.

    returns

    TxReport

  46. def transactAsync(rawTxStmts: List[AnyRef])(implicit ec: ExecutionContext): Future[TxReport]

    Asynchronously transact edn files or other raw transaction data.

    Asynchronously transact edn files or other raw transaction data.

    val data_rdr2 = new FileReader("examples/resources/seattle/seattle-data1a.dtm")
    val rawTxStmts = Util.readAll(data_rdr2).get(0).asInstanceOf[java.util.List[Object]]
    
    // transact
    val result: Future[TxReport] = conn.transactAsync(rawTxStmts)
    rawTxStmts

    Raw transaction data, typically from edn file.

    returns

    Future with TxReport with result of transaction

  47. final def tupleToSeq(arg: Any): Seq[Any]
    Attributes
    protected
    Definition Classes
    Helpers
  48. def useLiveDb: Unit

    Get out of test mode and back to live db.

  49. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  50. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  51. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )
  52. object mkDate
    Attributes
    protected
    Definition Classes
    Helpers

Inherited from Helpers

Inherited from AnyRef

Inherited from Any

Ungrouped