Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 44 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ OrientDB Scala DSL
**It's a Scala DSL for OrientDb...**

[![Build Status](https://travis-ci.org/acme-software/orientdb-scala-dsl.svg?branch=master)](https://travis-ci.org/acme-software/orientdb-scala-dsl)

[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/acme-software/orientdb-scala-dsl/master/LICENSE)
![Scala 2.11](https://img.shields.io/badge/scala-2.11-lightgrey.svg)
![Scala 2.12](https://img.shields.io/badge/scala-2.12-lightgrey.svg)

*Disclaimer:*
*Neiher this code, documentation nor any part of this repository is officially connected/related to
Expand Down Expand Up @@ -69,24 +71,58 @@ g.getVertexType("Person").dsl withProperty "age" -> INTEGER
```scala
// things needed from java driver
import com.tinkerpop.blueprints.impls.orient.OrientGraphFactory
import com.orientechnologies.orient.core.metadata.schema.OType._

// java converters for collections
import scala.collection.JavaConverters._

// scala dsl import
import ch.acmesoftware.orientDbScalaDsl._

val g = new OrientGraphFactory("memory:orientDbScalaDslTest").getNoTx
val g = new OrientGraphFactory("memory:orientDbScalaDslTest").getTx

// add vertex
g.dsl addVertex "Person" withProperty "name" -> "Frank"
g.dsl addVertex "Customer" withProperty "name" -> "ACME" and "active" -> true
g.dsl addVertex "Customer" withProperty "name" -> Some("ACME") and "active" -> None // only "name" is persisted
g.dsl addVertex "Customer" withProperty "name" -> null // ugly, but no exception - don't work with null in Scala ;)

// find & filter
g.dsl findVertices "City" single()
g.dsl findVertices "City" filter "name" -> "Zurich" filter "zip" -> 8000 single() // Option[VertexDsl]
g.dsl findVertices "City" filter "name" -> "Zurich" list() // Iterable[VertexDsl]
g.dsl findVertices "City" filter "name" -> "Zurich" list() take 3 // Iterable[VertexDsl] (first 3)

// edit existing
val existing = g.getVerticesOfClass("Customer").asScala.last
existing.dsl withProperty "name" -> "ACME Software Solutions" and "year" -> 2017
val existing = g.dsl findVertices "Customer" single()
existing foreach(_ withProperty "name" -> "ACME Software Solutions" and "year" -> 2017)

// get property
val name: Option[String] = existing.flatMap(v => v.property[String]("name"))

// get mandatory property (nullable) - only use this with schema
val name2: String = existing.map(v => v.mandatoryProperty[String]("name")).orNull
```

### Edge Type

TBD

### Edge

```scala
// things needed from java driver
import com.tinkerpop.blueprints.impls.orient.OrientGraphFactory

// scala dsl import
import ch.acmesoftware.orientDbScalaDsl._

val g = new OrientGraphFactory("memory:orientDbScalaDslTest").getTx

val company = g.dsl addVertex "Company"
val employee = g.dsl addVertex "Employee"

// create edge: Employee --(WorksFor)--> Company
val e1 = g.dsl addEdge "WorksFor" -> (employee -> company)

// add properties...
e1 withProperty "sinde" -> 2011 and "position" -> "Manager"
```

Get Involved
Expand Down
11 changes: 11 additions & 0 deletions bin/prepare-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash

# pre release tasks
sbt +test +doc

# sync documentation
rm -rf docs/api
mkdir -p docs/api/2.11
mkdir -p docs/api/2.12
cp -R target/scala-2.11/api/* docs/api/2.11
cp -R target/scala-2.12/api/* docs/api/2.12
6 changes: 3 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ scalacOptions in Compile ++= Seq(
"-Xlint"
)

scalacOptions ++= Seq(
"-J-Xms256M",
"-J-Xmx1G"
javaOptions in Test ++= Seq(
"-Xms256M",
"-Xmx1G"
)

libraryDependencies ++= Dependencies.db ++ Dependencies.testing
Expand Down
8 changes: 8 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
OrinteDn Scala DSL - Documentation
=================================

API Doc
-------

**[Scala 2.11](api/2.11/index.html)**
**[Scala 2.12](api/2.12/index.html)**
595 changes: 595 additions & 0 deletions docs/api/2.11/ch/acmesoftware/orientDbScalaDsl/EdgeDsl.html

Large diffs are not rendered by default.

Loading