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
    Definition Classes
    molecule
  • package schema

    Generic Schema attribute interfaces of all arities.

    Generic Schema attribute interfaces of all arities.

    The generic Schema interface provides attributes to build molecules that query the Schema structure of the current database.

    // List of attribute entity ids
    val attrIds: Seq[Long] = Schema.id.get
    
    // Attribute name elements
    Schema.a.part.ns.nsFull.attr.get === List (
      (":sales_Customer/name", "sales", "Customer", "sales_Customer", "name"),
      (":sales_Customer/name", "sales", "Customer", "sales_Customer", "name"),
      // etc..
    )
    
    // Datomic type and cardinality of attributes
    Schema.a.tpe.card.get === List (
      (":sales_Customer/name", "string", "one"),
      (":accounting_Invoice/invoiceLine", "ref", "many"),
    )
    
    // Optional docs and attribute options
    // These can be retrieved as mandatory or optional values
    Schema.a
          .index
          .doc$
          .unique$
          .fulltext$
          .isComponent$
          .noHistory$
          .get === List(
      (":sales_Customer/name",
        true,            // indexed
        "Customer name", // doc
        None,            // Uniqueness not set
        Some(true),      // Fulltext search set so that we can search for names
        None,            // Not a component
        None             // History is preserved (noHistory not set)
        ),
      (":accounting_Invoice/invoiceLine",
        true,                   // indexed
        "Ref to Invoice lines", // doc
        None,                   // Uniqueness not set
        None,                   // Fulltext search not set
        Some(true),             // Invoice is a component - owns invoice lines
        None                    // History is preserved (noHistory not set)
        ),
    )
    
    // Defined enum values
    Schema.a.enum.get.groupBy(_._1).map(g => g._1 -> g._2) === Map(
      ":Person/gender" -> List("female", "male"),
      ":Interests/sports" -> List("golf", "basket", "badminton")
    )
    
    // Schema transaction times
    Schema.t.tx.txInstant.get === List(
      (t1, tx1, <Date: 2018-11-07 09:28:10>), // Initial schema transaction
      (t2, tx2, <Date: 2019-01-12 12:43:27>), // Additional schema attribute definitions...
    )

    Apply expressions to narrow the returned selection of Schema data:

    // Namespaces in the "gen" partition (partition name tacit)
    Schema.part_("location").ns.get === List("Country", "Region", etc...)
    
    // Attributes in the "Person" namespace
    Schema.ns_("Person").attr.get === List("name", "age", "hobbies", etc...)
    
    // How many enum attributes?
    Schema.enum_.a(count).get === List(2)
    Definition Classes
    generic
    Note

    Schema attributes defined in Datomic's bootstrap process that are not related to the current database are transparently filtered out from all Schema queries.

    See also

    Tests for more Schema query examples.

  • trait Schema extends GenericNs

    Base Schema trait with attribute types shared by all arity interfaces.

    Base Schema trait with attribute types shared by all arity interfaces.

    Definition Classes
    schema
  • a
  • attr
  • card
  • doc
  • doc$
  • enum
  • fulltext
  • fulltext$
  • id
  • index
  • index$
  • isComponent
  • isComponent$
  • noHistory
  • noHistory$
  • ns
  • nsFull
  • part
  • t
  • tpe
  • tx
  • txInstant
  • unique
  • unique$

final class doc$[Ns, In] extends OneString$[Ns] with Indexed with Fulltext[Ns, In]

Optional documentation string.

Source
Schema.scala
Linear Supertypes
Fulltext[Ns, In], api.core.FulltextExpr[Ns, In], Indexed, OneString$[Ns], OneValueAttr$[Ns, String], api.core.OptionalExpr[Ns, String], ValueAttr$[String], Attr, AnyRef, Any
Type Hierarchy
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. doc$
  2. Fulltext
  3. FulltextExpr
  4. Indexed
  5. OneString$
  6. OneValueAttr$
  7. OptionalExpr
  8. ValueAttr$
  9. Attr
  10. AnyRef
  11. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Instance Constructors

  1. new doc$()

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(some: Option[String]): Ns with Attr

    Apply optional attribute value in save molecule.

    Apply optional attribute value in save molecule.

    val benAge = Some(42)
    val lizAge = None
    
    // Save optional `age` values
    Person.name("Ben").age$(benAge).save
    Person.name("Liz").age$(lizAge).save
    
    Person.name.age$.get === List(
      ("Ben", Some(42)),
      ("Liz", None),
    )
    some

    Optional attribute value to be saved

    returns

    Save-molecule

    Definition Classes
    OptionalExpr
  5. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  6. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native()
  7. def contains(words: api.core.??): In with Attr

    Mark as input molecule with String attribute word search.

    Mark as input molecule with String attribute word search.

    Fulltext searches are case-insensitive and only searches for whole words.

    Phrase.id.txt.get === List(
      (1, "The quick fox jumps"),
      (2, "Ten slow monkeys")
    )
    
    // Mark as input molecule awaiting word(s) to search for
    val phraseFinder = m(Phrase.id.txt_.contains(?))
    
    // Then we can apply words to the input molecule at runtime:
    
    phraseFinder("jumps").get === List(1)
    
    // Only whole words matched
    phraseFinder("jump").get === Nil
    
    // Searches are case-insensitive
    phraseFinder("JuMpS").get === List(1)
    
    // Empty spaces ignored
    phraseFinder("   jumps   ").get === List(1)
    
    // Multiple search words have OR semantics
    phraseFinder("jumps", "slow").get === List(1, 2)
    
    // Common words ignored
    phraseFinder("The").get === Nil
    words

    Search words

    returns

    Input molecule awaiting search word(s)

    Definition Classes
    FulltextExpr
    Note

    Fulltext search is constrained by several defaults (which cannot be altered): searches are case insensitive, remove apostrophe or apostrophe and s sequences, and filter out the following common English stop words: "a", "an", "and", "are", "as", "at", "be", "but", "by", "for", "if", "in", "into", "is", "it", "no", "not", "of", "on", "or", "such", "that", "the", "their", "then", "there", "these", "they", "this", "to", "was", "will", "with"

  8. def contains(word: String, moreWords: String*): Ns with Attr

    Match words of String attribute.

    Match words of String attribute.

    Fulltext searches are case-insensitive and only searches for whole words.

    Phrase.id.txt.get === List(
      (1, "The quick fox jumps"),
      (2, "Ten slow monkeys")
    )
    
    Phrase.id.txt_.contains("jumps").get === List(1)
    
    // Only whole words matched
    Phrase.id.txt_.contains("jump").get === Nil
    
    // Searches are case-insensitive
    Phrase.id.txt_.contains("JuMpS").get === List(1)
    
    // Empty spaces ignored
    Phrase.id.txt_.contains("   jumps   ").get === List(1)
    
    // Multiple search words have OR semantics
    Phrase.id.txt_.contains("jumps", "slow").get === List(1, 2)
    
    // Common words ignored
    Phrase.id.txt_.contains("The").get === Nil
    word

    Search word

    moreWords

    Optional additional search words

    returns

    Filtered molecule

    Definition Classes
    FulltextExpr
    Note

    Fulltext search is constrained by several defaults (which cannot be altered): searches are case insensitive, remove apostrophe or apostrophe and s sequences, and filter out the following common English stop words: "a", "an", "and", "are", "as", "at", "be", "but", "by", "for", "if", "in", "into", "is", "it", "no", "not", "of", "on", "or", "such", "that", "the", "their", "then", "there", "these", "they", "this", "to", "was", "will", "with"

  9. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  10. def equals(arg0: AnyRef): 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[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  13. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  14. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  15. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  16. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  17. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  18. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  19. def toString(): String
    Definition Classes
    AnyRef → Any
  20. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  21. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  22. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()

Inherited from Fulltext[Ns, In]

Inherited from api.core.FulltextExpr[Ns, In]

Inherited from Indexed

Inherited from OneString$[Ns]

Inherited from OneValueAttr$[Ns, String]

Inherited from api.core.OptionalExpr[Ns, String]

Inherited from ValueAttr$[String]

Inherited from Attr

Inherited from AnyRef

Inherited from Any

Ungrouped