All Projects → scalamolecule → Molecule

scalamolecule / Molecule

Scala meta-DSL for the Datomic database

Programming Languages

scala
5932 projects
dsl
153 projects

Labels

Projects that are alternatives of or similar to Molecule

Indradb
A graph database written in rust
Stars: ✭ 1,035 (+1929.41%)
Mutual labels:  database
Postgresclientkit
A PostgreSQL client library for Swift. Does not require libpq.
Stars: ✭ 49 (-3.92%)
Mutual labels:  database
Fluent Sqlite Driver
Fluent driver for SQLite
Stars: ✭ 51 (+0%)
Mutual labels:  database
Bigbang
Android base project used by Xmartlabs team
Stars: ✭ 47 (-7.84%)
Mutual labels:  database
Nsdb
Natural Series Database
Stars: ✭ 49 (-3.92%)
Mutual labels:  database
Couchdb Net
EF Core-like CouchDB experience for .NET!
Stars: ✭ 50 (-1.96%)
Mutual labels:  database
Exonum
An extensible open-source framework for creating private/permissioned blockchain applications
Stars: ✭ 1,037 (+1933.33%)
Mutual labels:  database
Laravel Transactional Model Events
Add eloquent model events fired after a transaction is committed or rolled back
Stars: ✭ 52 (+1.96%)
Mutual labels:  database
Spring Boot Angular5
This repository has a sample code base for spring boot and angular 5 integration.
Stars: ✭ 49 (-3.92%)
Mutual labels:  database
Awesome Ebooks
收录开源的经典技术书籍 PDF 文件及相关网站,持续更新中...
Stars: ✭ 51 (+0%)
Mutual labels:  database
Db
Helper tools for interacting with databases
Stars: ✭ 47 (-7.84%)
Mutual labels:  database
Rom Repository
THIS PROJECT WAS MOVED TO rom-rb/rom
Stars: ✭ 48 (-5.88%)
Mutual labels:  database
Rqlite
The lightweight, distributed relational database built on SQLite
Stars: ✭ 9,147 (+17835.29%)
Mutual labels:  database
Laravel Translatable
It's a Laravel database translations manager
Stars: ✭ 47 (-7.84%)
Mutual labels:  database
Hunt Entity
An object-relational mapping (ORM) framework for D language (Similar to JPA / Doctrine), support PostgreSQL and MySQL.
Stars: ✭ 51 (+0%)
Mutual labels:  database
Docker Redis Cluster
Dockerfile for Redis Cluster (redis 3.0+)
Stars: ✭ 1,035 (+1929.41%)
Mutual labels:  database
Racingworld
💥 A multiplayer online 3D game about racing 💥
Stars: ✭ 50 (-1.96%)
Mutual labels:  database
Bibsearch
Download, manage, and search a BibTeX database.
Stars: ✭ 52 (+1.96%)
Mutual labels:  database
Mssql Cli
A command-line client for SQL Server with auto-completion and syntax highlighting
Stars: ✭ 1,061 (+1980.39%)
Mutual labels:  database
Faunadb Jvm
Scala and Java driver for FaunaDB
Stars: ✭ 50 (-1.96%)
Mutual labels:  database

Molecule is a type safe and intuitive Scala meta-DSL for the Datomic database.

Visit ScalaMolecule.org to learn more or visit the Molecule forum

Gitter

A meta-DSL

Molecule is a "meta-DSL" in the sense that your domain terms form the tokens of your queries and transactions.

So instead of fitting in your domain terms between commands like SELECT name, age FROM Person etc, or other query constructs in other database languages, you directly use your domain terms as tokens:

Person.name.age.get

This is possible since a schema is initially defined based on your domain terms:

trait Person {
  val name = oneString
  val age  = oneInt
}

When you compile your project with sbt compile, Molecule generates the necessary boilerplate code in order to be able to write the more intuitive query. Since the types of each attribute name and age is encoded in the schema definition we'll also get typed data back from our query.

val personsWithAge: List[(String, Int)] = Person.name.age.get

// or asynchronously
val personsWithAgeFut: Future[List[(String, Int)]] = Person.name.age.getAsync

Sync and Async APIs

Molecule offers both a synchronous and an asynchronous API for all query getters and transaction operations.

Producing Datalog

Molecule transform "molecules" like Person.name.age.get to Datalog queries for Datomic. The returned untyped data from Datomic is then casted by Molecule to the expected Scala type.

All queries are prepared at compile time by macros. So there is no overhead at runtime when running the queries.

Getting started

Try demo project

  1. git clone https://github.com/scalamolecule/molecule-demo.git
  2. cd molecule-demo
  3. sbt compile
  4. Open in your IDE
  5. Run tests and poke around...

Molecule in Scala project

Molecule is currently available for Scala (JVM, version 8 and later) and Scala.js (JavaScript). Scala 2.12 and Scala 2.13 are supported.

Add the following to your build files:

project/build.properties:

sbt.version=1.4.9

project/buildinfo.sbt:

addSbtPlugin("org.scalamolecule" % "sbt-molecule" % "0.13.0")

build.sbt:

lazy val yourProject = project.in(file("app"))
  .enablePlugins(MoleculePlugin)
  .settings(
    resolvers ++= Seq(
      "datomic" at "http://files.datomic.com/maven",
      "clojars" at "http://clojars.org/repo",
      Resolver.sonatypeRepo("releases")
    ),
    libraryDependencies ++= Seq(
      "org.scalamolecule" %% "molecule" % "0.25.1",
      "com.datomic" % "datomic-free" % "0.9.5697" // or pro (see README_pro)
    ),
    moleculeSchemas := Seq("app") // paths to your schema definition files...
  )

Molecule in a Scala.js project

Molecule AST's and other generic interfaces have been ported to Scala.js so that you can also work with Molecule on the client side. See the molecule-admin project for an example of how Molecule is used both on the server and client side.

project/buildinfo.sbt:

addSbtPlugin("org.scalamolecule" % "sbt-molecule" % "0.13.0")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.5.0")
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0")

build.sbt (CrossType.Full example):

import sbtcrossproject.CrossPlugin.autoImport.crossProject

lazy val yourProject = crossProject(JSPlatform, JVMPlatform)
  .in(file("."))

lazy val yourProjectJVM = yourProject.jvm
  .enablePlugins(MoleculePlugin)
  .settings(
    resolvers ++= Seq(
      "datomic" at "http://files.datomic.com/maven",
      "clojars" at "http://clojars.org/repo",
      Resolver.sonatypeRepo("releases")
    ),
    libraryDependencies ++= Seq(
      "org.scalamolecule" %% "molecule" % "0.25.1",
      "com.datomic" % "datomic-free" % "0.9.5697"
    ),
    moleculeSchemas := Seq("app") // paths to your schema definition files...
  )

lazy val yourProjectJS = yourProject.js
  .settings(
    libraryDependencies ++= Seq(
      ("org.scalamolecule" %%% "molecule" % "0.25.1")
        .exclude("com.datomic", "datomic-free")
    ),
    moleculeSchemas := Seq("app") // paths to your schema definition files...
  )

Note how we exclude the Datomic dependency on the js side (since Datomic is obviously not compiled to javascript).

Molecule is available at maven.

Author

Marc Grue

Credits/inspiration/acknowledgements

License

Molecule is licensed under the Apache License 2.0

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].