Last active
February 3, 2026 20:23
-
-
Save dacr/87d9e51368446f88587e9ef41d05d473 to your computer and use it in GitHub Desktop.
playing with arangodb using java driver and native serdes / published by https://github.com/dacr/code-examples-manager #74fcf308-56a6-458c-b068-82b1df2bc08d/6e16e3aab986a39cfb2310cf2bab0251b099f94e
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // summary : playing with arangodb using java driver and native serdes | |
| // keywords : arangodb, graphdb, javadriver, velocitypack, @testable, | |
| // publish : gist, corporate | |
| // authors : David Crosson | |
| // license : Apache License Version 2.0 (https://www.apache.org/licenses/LICENSE-2.0.txt) | |
| // id : 74fcf308-56a6-458c-b068-82b1df2bc08d | |
| // created-on : 2021-03-05T09:25:00Z | |
| // managed-by : https://github.com/dacr/code-examples-manager | |
| // execution : scala ammonite script (http://ammonite.io/) - run as follow 'amm scriptname.sc' | |
| // --------------------- | |
| //> using scala "3.4.2" | |
| //> using dep "com.arangodb:arangodb-java-driver:6.6.3" | |
| //> using dep "com.arangodb:velocypack-module-scala_2.13:1.2.1" | |
| // --------------------- | |
| import com.arangodb._ | |
| import com.arangodb.entity._ | |
| import com.arangodb.model.AqlQueryOptions | |
| import com.arangodb.util.MapBuilder | |
| import com.arangodb.velocypack.module.scala._ | |
| val arango = { | |
| new ArangoDB | |
| .Builder() | |
| .registerModule(new VPackScalaModule) | |
| .host("127.0.0.1", 8529) | |
| .user("root") | |
| .password("root") | |
| .build() | |
| } | |
| try { | |
| arango.createDatabase("example") | |
| } catch { | |
| case _ => | |
| } | |
| val db = arango.db("example") | |
| try { | |
| db.createCollection("sample") | |
| } catch { | |
| case _ => | |
| } | |
| import scala.beans.BeanProperty | |
| case class Someone( | |
| @BeanProperty var name: String, | |
| @BeanProperty var age: Int | |
| ) { | |
| def this() = this(name = "", age=0) | |
| } | |
| def cursorSomeone: ArangoCursor[Someone] = | |
| db.query( | |
| "FOR i IN @@collection RETURN i", | |
| new MapBuilder().put("@collection", "sample").get(), | |
| new AqlQueryOptions(), | |
| classOf[Someone] | |
| ) | |
| cursorSomeone.forEach { someone => | |
| println(someone) | |
| } | |
| arango.shutdown() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment