Skip to content

Instantly share code, notes, and snippets.

@dacr
Created June 28, 2024 23:14
Show Gist options
  • Save dacr/7a91c7d787e7edc7bcc808b4cfb2e13c to your computer and use it in GitHub Desktop.
Save dacr/7a91c7d787e7edc7bcc808b4cfb2e13c to your computer and use it in GitHub Desktop.
neo4j through neotypes - hello world / published by https://github.com/dacr/code-examples-manager #d4502d74-9ade-4fca-a400-12d1e7e18a13/36db70e6da53df1142f6d9dc3798d36799f895c3
// summary : neo4j through neotypes - hello world
// keywords : scala, scalatest, neo4j, neotypes, helloworld, cypher, dsl, @testable
// publish : gist
// authors : David Crosson
// license : Apache NON-AI License Version 2.0 (https://raw.githubusercontent.com/non-ai-licenses/non-ai-licenses/main/NON-AI-APACHE2)
// id : d4502d74-9ade-4fca-a400-12d1e7e18a13
// created-on : 2024-06-25T15:10:56+02:00
// managed-by : https://github.com/dacr/code-examples-manager
// run-with : scala-cli $file
// ---------------------
//> using scala "3.4.2"
//> using dep io.github.neotypes::neotypes-core:1.1.0
//> using dep org.neo4j.test:neo4j-harness:5.20.0
// ---------------------
import neotypes.GraphDatabase
import neotypes.mappers.ResultMapper
import neotypes.syntax.all.*
import org.neo4j.driver.AuthTokens
import scala.util.Using
import scala.concurrent.{Await, Future}
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.duration._
val builder =
org.neo4j.harness.Neo4jBuilders
.newInProcessBuilder()
Using(builder.build()) { embedded =>
val driver = GraphDatabase.asyncDriver[Future](embedded.boltURI(), AuthTokens.none())
val message = "RETURN 'hello world'".query(ResultMapper.string).single(driver)
Await.result(message.map(msg => println(msg)), 5.seconds)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment