Minimal project setup to test a Cloud setup locally without connecting to a server.
import sbt.Keys._
lazy val demo = project.in(file("."))
.aggregate(app)
.settings(name := "molecule-datomic-devlocal")
lazy val app = project.in(file("app"))
.enablePlugins(MoleculePlugin)
.settings(
scalaVersion := "2.13.4",
resolvers ++= Seq(
Resolver.sonatypeRepo("releases"),
"clojars" at "https://clojars.org/repo",
Resolver.mavenLocal
),
libraryDependencies ++= Seq(
"org.scalamolecule" %% "molecule" % "0.24.0",
"com.datomic" % "dev-local" % "0.9.229"
),
// path to domain model directory
moleculeDataModelPaths := Seq("app"),
// Generate Molecule boilerplate code with `sbt clean compile -Dmolecule=true`
moleculePluginActive := sys.props.get("molecule") == Some("true"),
// Let IDE detect created jars in unmanaged lib directory
exportJars := true
)
implicit val conn = Datomic_DevLocal("datomic-samples").recreateDbFrom(SampleSchema, "sampledb")
Or, when the database has been created, only connect to it:
implicit val conn = Datomic_DevLocal("datomic-samples").connect("sampledb")
Having an implicit connection in scope, we can start transacting and querying sampledb
with molecules:
// Transact
Person.name("John").age(24).save.eid
// Query
assert(Person.name.age.get.head == ("John", 24))
// etc..
Add/change definitions in the SampleDataModel and run sbt clean compile -Dmolecule=true
in your project root to have Molecule re-generate boilerplate code. Then you can try out using your new attributes in new molecules in SampleApp
.