Packages

t

molecule.datomic.base.api

DatomicEntity

trait DatomicEntity extends AnyRef

Ordering
  1. Grouped
  2. Alphabetic
  3. By Inheritance
Inherited
  1. DatomicEntity
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract def apply(attr1: String, attr2: String, moreAttrs: String*)(implicit ec: ExecutionContext): Future[List[Option[Any]]]
  2. abstract def apply[T](attr: String)(implicit ec: ExecutionContext): Future[Option[T]]
  3. abstract def attrs(implicit ec: ExecutionContext): Future[List[String]]
  4. abstract def getRetractStmts(txMeta1: Molecule, txMetaMore: Molecule*)(implicit ec: ExecutionContext): Future[Seq[Statement]]

    Get entity retraction transaction data without affecting the database.

    Get entity retraction transaction data without affecting the database.

    Call getRetractStmts to retrieve the generated transaction data of the method retract on an entity

    for {
      // Get entity id of Ben
      benId <- Person.e.name_("Ben").get.map(_.eid)
    
      // Retraction transaction data
      _ <- benId.getRetractStmts().map(_ ==> List(
        RetractEntity(17592186045453)
      ))
    } yield ()
    txMeta1

    tx meta data molecule

    txMetaMore

    Optional additional tx meta data molecules

    ec

    Implicit scala.concurrent.ExecutionContext

    returns

    Future[Seq[Statement]]

  5. abstract def getRetractStmts(implicit ec: ExecutionContext): Future[Seq[Statement]]

    Get entity retraction transaction data without affecting the database.

    Get entity retraction transaction data without affecting the database.

    Call getRetractStmts to retrieve the generated transaction data of the method retract on an entity

    for {
      // Get entity id of Ben
      benId <- Person.e.name_("Ben").get.map(_.eid)
    
      // Retraction transaction data
      _ <- benId.getRetractStmts.map(_ ==> List(RetractEntity(17592186045453)))
    } yield ()
    ec

    Implicit scala.concurrent.ExecutionContext

    returns

    Future[Seq[Statement]]

  6. abstract def graph(implicit ec: ExecutionContext): Future[Map[String, Any]]

    Get entity graph as Map.

    Get entity graph as Map.

    If entity has reference(s) to other entities it can be a nested graph. Default max levels retrieved is 5.

    • Keys of returned Map are namespaced names of attributes
    • Values of returned Map are untyped attribute values. For references to other entities, the value is a Map itself of the referenced entity attributes, etc.
    for {
      benId <- Person.name.age.Address.street.insert("Ben", 42, "Hollywood Rd").map(_.eid)
    
      _ <- benId.graph.map(_ ==-< Map(
        ":db/id" -> 17592186045445L,
        ":Person/age" -> 42,
        ":Person/address" -> Map(
          ":db/id" -> 17592186045446L,
          ":Address/street" -> "Hollywood Rd"),
        ":Person/name" -> "Ben"
      ))
    } yield ()
    returns

    Map[key: String, value: Any] where value can be a primitive or another nested Map of the entity graph

  7. abstract def graphCode(maxDepth: Int)(implicit ec: ExecutionContext): Future[String]

    Get entity graph as String with code for copy/paste into tests.

  8. abstract def graphDepth(maxDepth: Int)(implicit ec: ExecutionContext): Future[Map[String, Any]]

    Get entity graph to some depth as Map.

    Get entity graph to some depth as Map.

    • Keys of returned Map are namespaced names of attributes
    • Values of returned Map are untyped attribute values. For references to other entities, the value is a Map itself of the referenced entity attributes, etc.
    for {
      benId <- Person.name.age.Address.street.insert("Ben", 42, "Hollywood Rd").map(_.eid)
    
      // 2 levels returned
      _ <- benId.graphDepth(2).map(_ ==> Map(
        ":db/id" -> 17592186045445L,
        ":Person/age" -> 42,
        ":Person/address" -> Map(
          ":db/id" -> 17592186045446L,
          ":Address/street" -> "Hollywood Rd"),
        ":Person/name" -> "Ben"
      ))
    
      // 1 level returned
      _ <- benId.graphDepth(1).map(_ ==> Map(
        ":db/id" -> 17592186045445L,
        ":Person/age" -> 42,
        ":Person/address" -> 17592186045446L // Only reference returned
        ":Person/name" -> "Ben"
      ))
    } yield ()
    returns

    Map[key: String, value: Any] where value can be a primitive or another nested Map of the entity graph

  9. abstract def inspectGraph(implicit ec: ExecutionContext): Future[Unit]

    Print entity graph as Map-string (for presentation).

    Print entity graph as Map-string (for presentation).

    To show the entity graph, this method quotes all text strings so that you can paste the whole graph into any presentation.

    If the entity has reference(s) to other entities it can be a nested graph. Default max levels retrieved is 5.

    • Keys of returned Map are namespaced names of attributes
    • Values of returned Map are untyped attribute values. For references to other entities, the value is a Map itself of the referenced entity attributes, etc.
    for {
      benId <- Person.name.age.Address.street.insert("Ben", 42, "Hollywood Rd").map(_.eid)
    
      _ <- benId.graphCode.map(_ ==>
        """Map(
          |  ":db/id" -> 17592186045445L,
          |  ":Person/age" -> 42,
          |  ":Person/address" -> Map(
          |    ":db/id" -> 17592186045446L,
          |    ":Address/street" -> "Hollywood Rd"),
          |  ":Person/name" -> "Ben")""".stripMargin
      ))
    } yield ()
    returns

    String

  10. abstract def inspectGraphDepth(maxDepth: Int)(implicit ec: ExecutionContext): Future[Unit]

    Print entity graph to some depth as Map-string (for presentation).

    Print entity graph to some depth as Map-string (for presentation).

    To show the entity graph, this method quotes all text strings so that you can paste the whole graph into any presentation.

    • Keys of returned Map are namespaced names of attributes
    • Values of returned Map are untyped attribute values. For references to other entities, the value is a Map itself of the referenced entity attributes, etc.
    for {
      benId <- Person.name.age.Address.street.insert("Ben", 42, "Hollywood Rd").map(_.eid)
    
      // 2 levels (in this case all levels) returned
      _ <- benId.graphCodeDepth(2).map(_ ==>
        """Map(
          |  ":db/id" -> 17592186045445L,
          |  ":Person/age" -> 42,
          |  ":Person/address" -> Map(
          |    ":db/id" -> 17592186045446L,
          |    ":Address/street" -> "Hollywood Rd"),
          |  ":Person/name" -> "Ben")""".stripMargin
      ))
    
      // 1 level returned
      // Note that only reference to Address entity on level 2 is returned
      _ <- benId.graphCodeDepth(1).map(_ ==>
        """Map(
          |  ":db/id" -> 17592186045445L,
          |  ":Person/age" -> 42,
          |  ":Person/address" -> 17592186045446L,
          |  ":Person/name" -> "Ben")""".stripMargin
      ))
    } yield ()
    returns

    String

  11. abstract def inspectRetract(txMeta1: Molecule, txMetaMore: Molecule*)(implicit ec: ExecutionContext): Future[Unit]

    Inspect entity transaction data of method retract with tx meta data without affecting the database.

    Inspect entity transaction data of method retract with tx meta data without affecting the database.

    for {
      // Inspect retraction of an entity
      _ <- eid.inspectRetract(Ref2.str2("meta2") + Ref1.str1("meta1"))
    } yield ()

    This will print generated Datomic transaction statements in a readable format to output:

    ## 1 ## Inspect `retract` on entity with tx meta data
    =============================================================================
    list(
      RetractEntity(17592186045453),
      Add(datomic.tx,:Ref2/str2,meta2,Card(1)),
      Add(datomic.tx,:Ref1/str1,meta1,Card(1)))
       =============================================================================
    txMeta1

    tx meta data molecule

    txMetaMore

    Optional additional tx meta data molecules

    ec

    Implicit scala.concurrent.ExecutionContext

    returns

    Unit (prints data to console)

  12. abstract def inspectRetract(implicit ec: ExecutionContext): Future[Unit]

    Inspect entity transaction data of method retract without affecting the database.

    Inspect entity transaction data of method retract without affecting the database.

    for {
      // Inspect retraction of an entity
      _ <- eid.inspectRetract
    } yield ()

    This will print generated Datomic transaction statements in a readable format to output:

    ## 1 ## Inspect `retract` on entity
    =============================================================================
    list(
      RetractEntity(17592186045453))
    =============================================================================
    ec

    Implicit scala.concurrent.ExecutionContext

    returns

    Unit (prints data to console)

  13. abstract def retract(txMeta1: Molecule, txMetaMore: Molecule*)(implicit ec: ExecutionContext): Future[TxReport]

    Retract single entity using entity id and tx meta data.

    Retract single entity using entity id and tx meta data.

    Given the implicit conversion of Long's in molecule.datomic.base.api.EntityOps to an Entity we can can call retract on an entity id directly:

    for {
      eid <- Ns.int(1).save.map(_.eid)
    
      // Retract entity with tx meta data
      tx <- eid.retract(Ref2.str2("meta2"), Ref1.str1("meta1")).map(_.tx)
    
      // What was retracted and with what tx meta data
      _ <- Ns.e.int.tx.op_(false).Tx(Ref2.str2 + Ref1.str1).getHistory.map(_ ==> List(
        (eid, 1, tx, "meta2", "meta1")
      ))
    } yield ()

    To retract single entity id with tx meta data, use
    eid.Tx(MyMetaData.action("my meta data")).retract

    To retract multiple entities (with or without tx meta data), use
    retract(eids, txMetaDataMolecules*) in molecule.datomic.base.api.EntityOps.

    txMeta1

    tx meta data molecule

    txMetaMore

    Optional additional tx meta data molecules

    ec

    Implicit scala.concurrent.ExecutionContext

    returns

    molecule.datomic.base.facade.TxReport with result of retraction

  14. abstract def retract(implicit ec: ExecutionContext): Future[TxReport]

    Retract single entity using entity id.

    Retract single entity using entity id.

    Given the implicit conversion of Long's in molecule.datomic.base.api.EntityOps to an Entity we can can call retract on an entity id directly:

    for {
      // Get entity id of Ben
      benId <- Person.e.name_("Ben").get.map(_.eid)
    
      // Retract Ben entity
      _ <- benId.retract
    
      _ <- Person.name.get.map(_ ==> Nil)
    } yield ()

    To retract single entity id with tx meta data, use
    eid.Tx(MyMetaData.action("my meta data")).retract

    To retract multiple entities (with or without tx meta data), use
    retract(eids, txMetaDataMolecules*) in molecule.datomic.base.api.EntityOps.

    ec

    Implicit scala.concurrent.ExecutionContext

    returns

    molecule.datomic.base.facade.TxReport with result of retraction

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. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  6. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  7. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  8. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  9. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  10. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  11. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  12. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  13. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  14. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  15. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  16. def toString(): String
    Definition Classes
    AnyRef → Any
  17. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  18. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  19. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()

Inherited from AnyRef

Inherited from Any

entityGraph

retract

Ungrouped