Packages

p

molecule

package molecule

Type Members

  1. abstract class DomainStructure extends AnyRef

    Domain structure definition

    Domain structure definition

    Define a Domain structure to be handled by Molecule in an object that extends this Domain class.

    A domain structure consists of traits describing real world entities. Each entity/trait is given a name and defines a list of attributes that are the relevant properties of the entity.

    A maxArity number is applied to Domain to tell Molecule how many Attributes it should create boilerplate code for, or how many attribute values are expected at most to be returned from molecule queries. This is to generate a minimum of boilerplate code.

    package path.to.your.project
    import molecule.Domain
    
    object Community extends Domain(8) { // "Community" domain
    
      trait Person {          // "Person" entity
        val name = oneString  // Person "name" String attribute definition
        val age  = oneInt     // Person "age" Int attribute definition
      }
    
      // Additional entities...
    }

    For larger projects, it is recommended to organize the domain structure in segments of related entity traits within objects:

    object Seattle extends Domain(15) {
    
      object customer { // "customer" segment
        trait Person {
          val name    = oneString
          val age     = oneInt
          val address = one[Address]         // Cardinality-one relationship to Address
          val bought  = many[products.Item]  // Cardinality-many relationship to products.Item
        }
        trait Address {
          val street = oneString.fulltext
          val city   = oneInt
        }
        // ..more entities in the `customer` segment
      }
    
      object products { // "products" segment
        trait Item {
          val title   = oneString
          val inStock = oneInt
        }
        // ..more entities in the `products` segment
      }
    
      // Additional segments...
    }
  2. abstract class Graphql extends AnyRef
  3. abstract class REST extends AnyRef

Ungrouped