Tepkin alternatives and similar packages
Based on the "Database" category.
Alternatively, view Tepkin alternatives based on common mentions on social networks and blogs.
-
Slick
Slick (Scala Language Integrated Connection Kit) is a modern database query and access library for Scala -
Elastic4s
Elasticsearch Scala Client - Reactive, Non Blocking, Type Safe, HTTP Client -
PostgreSQL and MySQL async
Async database drivers to talk to PostgreSQL and MySQL in Scala. -
ScalikeJDBC
A tidy SQL-based DB access library for Scala developers. This library naturally wraps JDBC APIs and provides you easy-to-use APIs. -
scala-redis
A scala library for connecting to a redis server, or a cluster of redis nodes using consistent hashing on the client side. -
Phantom
Schema safe, type-safe, reactive Scala driver for Cassandra/Datastax Enterprise -
ReactiveMongo
:leaves: Non-blocking, Reactive MongoDB Driver for Scala -
rediscala
Non-blocking, Reactive Redis driver for Scala (with Sentinel support) -
Squeryl
A Scala DSL for talking with databases with minimum verbosity and maximum type safety -
SwayDB
Persistent and in-memory key-value storage engine for JVM that scales on a single machine. -
Pulsar4s
Idiomatic, typesafe, and reactive Scala client for Apache Pulsar -
#<Sawyer::Resource:0x00007f161059a678>
Strong type constraints for Scala -
scredis
Non-blocking, ultra-fast Scala Redis client built on top of Akka IO, used in production at Livestream -
Scala-Forklift
Type-safe data migration tool for Slick, Git and beyond. -
Scruid
Scala + Druid: Scruid. A library that allows you to compose queries in Scala, and parse the result back into typesafe classes. -
Clickhouse-scala-client
Clickhouse Scala Client with Reactive Streams support -
ScalaRelational
Type-Safe framework for defining, modifying, and querying SQL databases -
lucene4s
Light-weight convenience wrapper around Lucene to simplify complex tasks and add Scala sugar. -
GCP Datastore Akka Persistence Plugin
akka-persistence-gcp-datastore is a journal and snapshot store plugin for akka-persistence using google cloud firestore in datastore mode.
TestGPT | Generating meaningful tests for busy devs
Do you think we are missing an alternative of Tepkin or a related project?
Popular Comparisons
README
Deprecation Notice
This project has moved to https://github.com/jeroenr/tepkin
Tepkin
Reactive MongoDB Driver for Scala built on top of Akka IO and Akka Streams.
Only MongoDB 2.6+, Scala 2.11+ is supported. Java support has been dropped. See details here: https://github.com/fehmicansaglam/tepkin/issues/22
Don't hesitate to ask questions in the Tepkin Google Group or join chat on Gitter:
Contributions
Tepkin is a young but very active project and absolutely needs your help. Good ways to contribute include:
- Raising bugs and feature requests
- Fixing bugs
- Improving the performance
- Adding to the documentation
Please read our Scala Guide first: https://github.com/fehmicansaglam/tepkin/wiki/Scala-Guide
Quick Start
Setting up dependencies
Latest stable Tepkin release is 0.5 and is available on Maven Central. Just add the following dependency:
libraryDependencies ++= Seq(
"net.fehmicansaglam" %% "tepkin" % "0.5"
)
Or if you want to be on the bleeding edge using snapshots, latest snapshot release is 0.6-SNAPSHOT. Add the following repository and dependency:
resolvers += "Sonatype Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots/"
libraryDependencies ++= Seq(
"net.fehmicansaglam" %% "tepkin" % "0.6-SNAPSHOT"
)
Scala API
Working with BSON DSL
To construct a Bson document, you can either create BsonElements and join them with ~
or create a document directly.
import net.fehmicansaglam.bson.BsonDsl._
import net.fehmicansaglam.bson.Implicits._
import net.fehmicansaglam.bson.element.BsonObjectId
import org.joda.time.DateTime
// Construct a BsonDocument from BsonElements
val element = "name" := "Johny"
val document = element ~
("surname" := "Doe") ~
("age" := 28) ~
("months" := $array(1, 2, 3))
// Construct a BsonDocument
val document = $document(
"_id" := BsonObjectId.generate,
"name" := "Johny",
"surname" := "Doe",
"age" := 28,
"months" := $array(1, 2, 3),
"details" := $document(
"salary" := 455.5,
"inventory" := $array("a", 3.5, 1L, true),
"birthday" := new DateTime(1987, 3, 5, 0, 0)
)
)
There is an implicit conversion from any BsonElement
to BsonDocument
for convenience.
import net.fehmicansaglam.bson.BsonDocument
import net.fehmicansaglam.bson.element.BsonElement
import net.fehmicansaglam.bson.BsonDsl._
import net.fehmicansaglam.bson.Implicits._
val element: BsonElement = "name" := "fehmi"
val document: BsonDocument = "name" := "fehmi"
Connecting to MongoDB
To make a connection to MongoDB, use the MongoClient
interface.
import net.fehmicansaglam.tepkin.MongoClient
// Connect to a MongoDB node.
val client = MongoClient("mongodb://localhost")
MongoClient
manages multiple connection pools to MongoDB instances and therefore is a heavy class. Most of the time you will need only one MongoClient
instance per application.
Use MongoDatabase
and MongoCollection
in order to obtain a reference to a database and a collection.
// Obtain a reference to the "tepkin" database
val db = client("tepkin")
// Obtain a reference to the "example" collection in "tepkin" database.
val collection = db("example")
MongoDatabase
and MongoCollection
are lightweight classes and may be instantiated more than once if needed. However they are both immutable and reusable.
All methods in the MongoCollection
class need an implicit scala.concurrent.ExecutionContext
and an akka.util.Timeout
. You can define a default timeout and use the client's execution context as shown below:
import akka.util.Timeout
import scala.concurrent.duration._
// val client = ...
import client.ec
implicit val timeout: Timeout = 5.seconds
Find documents
import net.fehmicansaglam.bson.BsonDocument
import net.fehmicansaglam.bson.BsonDsl._
import net.fehmicansaglam.bson.Implicits._
val query: BsonDocument = "name" := "fehmi"
val source = collection.find(query)
All find methods in Tepkin return an akka.stream.scaladsl.Source[List[BsonDocument], ActorRef]
. Then you can use any method in Akka Streams to process the returned stream.
Insert operations
Insert a single document
import net.fehmicansaglam.bson.BsonDsl._
import net.fehmicansaglam.bson.Implicits._
val document = ("name" := "fehmi") ~ ("surname" := "saglam")
collection.insert(document)
Insert a collection of documents
import net.fehmicansaglam.bson.BsonDsl._
import net.fehmicansaglam.bson.Implicits._
val documents = (1 to 100).map(i => $document("name" := s"fehmi$i"))
collection.insert(documents)
Insert a large number of documents from a stream
import akka.stream.ActorFlowMaterializer
import akka.stream.scaladsl.Source
import net.fehmicansaglam.bson.BsonDocument
import net.fehmicansaglam.bson.BsonDsl._
import net.fehmicansaglam.bson.Implicits._
import scala.collection.immutable.Iterable
implicit val mat = ActorFlowMaterializer()(client.context)
val documents: Source[List[BsonDocument], Unit] = Source {
Iterable.tabulate(100) { _ =>
(1 to 1000).map(i => $document("name" := s"fehmi$i")).toList
}
}
collection.insertFromSource(documents).runForeach(_ => ())
Other queries
Update
import net.fehmicansaglam.bson.BsonDsl._
import net.fehmicansaglam.bson.Implicits._
import scala.concurrent.Future
val document = ("name" := "fehmi") ~ ("surname" := "saglam")
val result: Future[UpdateResult] = for {
insert <- collection.insert(document)
update <- collection.update(
query = "name" := "fehmi",
update = $set("name" := "fehmi can")
)
} yield update
Find and update
Update and return the old document.
import net.fehmicansaglam.bson.BsonDsl._
import net.fehmicansaglam.bson.Implicits._
collection.findAndUpdate(
query = Some("name" := "fehmi"),
update = $set("name" := "fehmi can")
)
Update and return the updated document.
import net.fehmicansaglam.bson.BsonDsl._
import net.fehmicansaglam.bson.Implicits._
collection.findAndUpdate(
query = Some("name" := "fehmi"),
update = $set("name" := "fehmi can"),
returnNew = true
)
Create index
import net.fehmicansaglam.bson.BsonDsl._
import net.fehmicansaglam.bson.Implicits._
import net.fehmicansaglam.tepkin.protocol.command.Index
collection.createIndexes(Index(name = "name_surname", key = ("name" := 1) ~ ("surname" := 1)))
Donations
Tepkin is a free software project and will always be. I work hard to make it stable and to add new features. I am always available if you encounter a problem and file an issue on Github. If you like Tepkin and find it helpful, you might give me a gift from some of the books (Kindle) I have in my wish list:
My Wish List on Amazon. Thanks!
One last thing, I am available for hire. If you think you know a job that is suitable for me, especially in Europe, please contact me at fehmican dot saglam at gmail dot com.
*Note that all licence references and agreements mentioned in the Tepkin README section above
are relevant to that project's source code only.