Packages

c

molecule.datomic.base.api.EntityOps

long2DatomicEntity

implicit class long2DatomicEntity extends DatomicEntity

Convenience conversion from entity id to DatomicEntity api

Source
EntityOps.scala
Linear Supertypes
DatomicEntity, AnyRef, Any
Type Hierarchy
Ordering
  1. Grouped
  2. Alphabetic
  3. By Inheritance
Inherited
  1. long2DatomicEntity
  2. DatomicEntity
  3. AnyRef
  4. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new long2DatomicEntity(id: Long)(implicit conn: Future[Conn], ec: ExecutionContext)

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 apply(attr1: String, attr2: String, moreAttrs: String*)(implicit ec: ExecutionContext): Future[List[Option[Any]]]
    Definition Classes
    long2DatomicEntityDatomicEntity
  5. def apply[T](attr: String)(implicit ec: ExecutionContext): Future[Option[T]]
    Definition Classes
    long2DatomicEntityDatomicEntity
  6. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  7. def attrs(implicit ec: ExecutionContext): Future[List[String]]
    Definition Classes
    long2DatomicEntityDatomicEntity
  8. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  9. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  10. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  11. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  12. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  13. 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]]

    Definition Classes
    long2DatomicEntityDatomicEntity
  14. 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]]

    Definition Classes
    long2DatomicEntityDatomicEntity
  15. 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

    Definition Classes
    long2DatomicEntityDatomicEntity
  16. def graphCode(maxDepth: Int)(implicit ec: ExecutionContext): Future[String]

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

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

    Definition Classes
    long2DatomicEntityDatomicEntity
  17. 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

    Definition Classes
    long2DatomicEntityDatomicEntity
  18. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  19. 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

    Definition Classes
    long2DatomicEntityDatomicEntity
  20. 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

    Definition Classes
    long2DatomicEntityDatomicEntity
  21. 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)

    Definition Classes
    long2DatomicEntityDatomicEntity
  22. 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)

    Definition Classes
    long2DatomicEntityDatomicEntity
  23. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  24. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  25. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  26. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  27. 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

    Definition Classes
    long2DatomicEntityDatomicEntity
  28. 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

    Definition Classes
    long2DatomicEntityDatomicEntity
  29. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  30. def toString(): String
    Definition Classes
    AnyRef → Any
  31. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  32. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  33. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()

Inherited from DatomicEntity

Inherited from AnyRef

Inherited from Any

entityGraph

retract

Ungrouped