A non-blocking asynchronous
domain-customizable database query language
for Scala and Scala.js against the Datomic® db

Fetch data as tuples, objects or json

Build intuitive queries with your domain terms

Person.name.age.Address.street.get.map { tuples =>
  tuples.head ==> ("Lisa", 20, "Broadway")
}

Person.name.age.Address.street.getObjs.map { objects =>
  val obj = objects.head
  obj.name ==> "Lisa"
  obj.age ==> 20
  obj.Address.street ==> "Broadway"
}

Person.name.age.Address.street.getJson.map { json =>
  json ==>
    """{
      |  "data": {
      |    "Person": [
      |      {
      |        "name": "Lisa",
      |        "age": 20,
      |        "Address": {
      |          "street": "Broadway"
      |        }
      |      }
      |    ]
      |  }
      |}""".stripMargin
}

Make transparent RPC calls with Scala.js

Transact and fetch data with molecules transparently from the js platform
without shared interfaces and sever implementations. Read more..

Traditional rpc

// js
val personApi = ... // rpc setup
personApi.personAge("Lisa").map(age =>
  body.appendChild(
    div("Lisa's age: " + age).render
  )
)
// shared
trait PersonApi {
  def personAge(name: String): Future[Int]
}
// jvm
object PersonImpl extends PersonApi {
  def personAge(name: String) = {
    Person.name_(name).age.get.map(_.head)
  }
}

Transparent rpc

// js
Person.name_("Lisa").age.getObj.map(lisa =>
  body.appendChild(
    div("Lisa's age: " + lisa.age).render
  )
)

Your Domain terms as Query Language

Use a Data Model of your Domain to build
type-inferred molecules for both transactions and queries

Model

trait Person {
  val name    = oneString
  val age     = oneInt
  val address = one[Address]
}
trait Address {
  val street = oneString
}

Transact

Person.name.age.Address.street insert
  List(
    ("Lisa", 20, "Broadway"),
    ("John", 24, "5th Avenue")
  )

Query

Person.name.age.Address.street.get
  .map(_ ==> List(
    ("Lisa", 20, "Broadway"),
    ("John", 24, "5th Avenue")
  ))

Same molecules for multiple dbs

Transact and query uniformly with your molecule api against any of the three Datomic database systems: Peer, Peer-Server and Cloud.

One molecule api

Datomic
Peer

On-prem

Peer in application process

Datomic
Peer-Server

Remote Peer via http

Like traditional db server

Datomic
Cloud

Distributed AWS Cloud system

Testable with dev-Local

Molecule

  • Non-blocking and asynchronous
  • Type-inferred transactions and queries
  • Your Domain terms used as tx/query tokens
  • Transparent RPC on Scala.js platform
  • RDBMS, Graph, Document, KV-store all-in-one
  • Transactions and queries built at compile time
  • Automatic Query optimization
  • Built-in auditing and time queries
  • Test against automatically garbage-collected db "branches"
  • Read more...

Datomic®

  • Datomic official website
  • Fully transactional, cloud-ready, distributed database
  • Elastic scaling
  • Built-in caching - extremely low latency
  • Built-in auditing - query entire history of data
  • ACID-compliant transactions
  • Flexible and sound Data Model
  • Strong industry support

Check samples

  1. git clone https://github.com/scalamolecule/molecule-samples.git
  2. Open in your IDE
  3. Run app - and build new molecules…

Read more