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 generic

    Interfaces to get generic information about data and schema.

    Interfaces to get generic information about data and schema.

    • Datom - Datom attributes in molecules
    • Log - Datoms sorted by transaction/time
    • EAVT - Datoms sorted by Entity-Attribute-Value-Transaction
    • AVET - Datoms sorted by Attribute-Value-Entity-Transaction
    • AEVT - Datoms sorted by Attribute-Entity-Value-Transaction
    • VAET - "Reverse index" for reverse lookup of ref types
    • Schema - Meta information about the current database schema.
    Definition Classes
    molecule
  • package index

    Datomic Index APIs in Molecule.

    Datomic Index APIs in Molecule.

    Datomic maintains four indexes that contain ordered sets of datoms. Each of these indexes is named based on the sort order used:

    • EAVT - Datoms sorted by Entity-Attribute-Value-Transaction
    • AVET - Datoms sorted by Attribute-Value-Entity-Transaction
    • AEVT - Datoms sorted by Attribute-Entity-Value-Transaction
    • VAET - "Reverse index" for reverse lookup of ref types

    Create an Index molecule by instantiating an Index object with one or more arguments in the order of the Index's elements. Datoms are returned as tuples of data depending of which generic attributes you add to the Index molecule:

    // Create EAVT Index molecule with 1 entity id argument
    EAVT(e1).e.a.v.t.get === List(
      (e1, ":Person/name", "Ben", t1),
      (e1, ":Person/age", 42, t2),
      (e1, ":Golf/score", 5.7, t2)
    )
    
    // Maybe we are only interested in the attribute/value pairs:
    EAVT(e1).a.v.get === List(
      (":Person/name", "Ben"),
      (":Person/age", 42),
      (":Golf/score", 5.7)
    )
    
    // Two arguments to narrow the search
    EAVT(e1, ":Person/age").a.v.get === List(
      (":Person/age", 42)
    )
    Definition Classes
    generic
    Note

    The Molecule Index API's don't allow returning the whole Index/the whole database. So omitting arguments constructing the Index object (like EAVT.e.a.v.t.get) will throw an exception.
    Please use Datomics API if you need to return the whole database Index:
    conn.db.datoms(datomic.Database.EAVT)

    See also

    Tests for more Index query examples.

  • AEVT
  • AEVT_0
  • AEVT_1
  • AEVT_2
  • AEVT_3
  • AEVT_4
  • AEVT_5
  • AEVT_6
  • AEVT_7
  • AVET
  • AVET_0
  • AVET_1
  • AVET_2
  • AVET_3
  • AVET_4
  • AVET_5
  • AVET_6
  • AVET_7
  • EAVT
  • EAVT_0
  • EAVT_1
  • EAVT_2
  • EAVT_3
  • EAVT_4
  • EAVT_5
  • EAVT_6
  • EAVT_7
  • GenericAEVT
  • GenericAVET
  • GenericEAVT
  • GenericVAET
  • VAET
  • VAET_0
  • VAET_1
  • VAET_2
  • VAET_3
  • VAET_4
  • VAET_5
  • VAET_6
  • VAET_7

trait AVET extends GenericNs

AVET Index.

"The AVET index provides efficient access to particular combinations of attribute and value." (from Datomic documentation)

Access the AVET Index in Molecule by instantiating an AVET object with one or more arguments and then add generic attributes:

// Create AVET Index molecule with 1 entity id argument
AVET(":Person/age").e.v.t.get === List(
  (e1, 42, t2),
  (e2, 37, t5)
  (e3, 14, t7),
)

// Narrow search with multiple arguments
AVET(":Person/age", 42).e.t.get === List( (e1, t2) )
AVET(":Person/age", 42, e1).e.v.get === List( (e1, t2) )
AVET(":Person/age", 42, e1, t2).e.v.get === List( (e1, t2) )

The AVET Index can be filtered by a range of values between from (inclusive) and until (exclusive) for an attribute:

AVET.range(":Person/age", Some(14), Some(37)).v.e.t.get === List(
  (14, e4, t7) // 14 is included in value range
               // 37 not included in value range
               // 42 outside value range
)

// If `from` is None, the range starts from the beginning
AVET.range(":Person/age", None, Some(40)).v.e.t.get === List(
  (14, e3, t7),
  (37, e2, t5),
)

// If `until` is None, the range goes to the end
AVET.range(":Person/age", Some(20), None).v.e.t.get === List(
  (37, e2, t5),
  (42, e1, t2)
)

Index attributes available:

  • e - Entity id (Long)
  • a - Full attribute name like ":Person/name" (String)
  • v - Value of Datoms (Any)
  • t - Transaction pointer (Long/Int)
  • tx - Transaction entity id (Long)
  • txInstant - Transaction wall clock time (java.util.Date)
  • op - Operation status: assertion (true) / retraction (false)
Source
AVET.scala
Note

The Molecule Index API's don't allow returning the whole Index/the whole database. So omitting arguments constructing the Index object (like AVET.a.v.e.t.get) will throw an exception.
Please use Datomics API if you need to return the whole database Index:
conn.db.datoms(datomic.Database.AVET)

from and until cannot both be None since Molecule doesn't allow returning all datoms.

See also

Tests for more Index query examples.

Linear Supertypes
GenericNs, AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. AVET
  2. GenericNs
  3. AnyRef
  4. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. final class a[Ns, In] extends OneString[Ns, In] with Indexed

    (Partition)-Namespace-prefixed attribute name (":part_Ns/attr")

  2. final class e[Ns, In] extends OneLong[Ns, In] with Indexed

    Entity id (Long)

  3. final class op[Ns, In] extends OneBoolean[Ns, In] with Indexed

    Transaction operation: assertion (true) or retraction (false)

  4. final class t[Ns, In] extends OneLong[Ns, In] with Indexed

    Transaction point in time t (Long/Int)

  5. final class tx[Ns, In] extends OneLong[Ns, In] with Indexed

    Transaction entity id (Long)

  6. final class txInstant[Ns, In] extends OneDate[Ns, In] with Indexed

    Transaction wall-clock time (Date)

  7. final class v[Ns, In] extends OneAny[Ns, In] with Indexed

    Datom value (Any)

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 GenericNs

Inherited from AnyRef

Inherited from Any

Ungrouped