solutions.bitbadger.documents
Treat PostgreSQL and SQLite as document stores from Java, Kotlin, Scala, and Groovy
Examples
// Retrieve (find) all orders (Java)
public List<Order> findOrders(Connection conn) {
Find.all(/*table name*/ "order", /*type*/ Order.class, conn);
}
// Mark an order as fulfilled (Kotlin)
fun markFulfilled(orderId: Long, conn: Connection) =
conn.patchById(
/*table name*/ "order",
/*document ID*/ orderId,
/*patch object*/ mapOf("fulfilled" to true)
)
// Delete orders marked as obsolete (Scala)
def deleteObsolete(Connection conn):
conn.deleteByFields(/*table name*/ "order",
/*field criteria*/ Field.equal("obsolete", true) :: Nil)
// Remove the pending status from multiple orders (Groovy)
void clearPending(List<Long> orderIds, Connection conn) {
conn.removeFieldsByFields(/*table name*/ "order",
/*field criteria*/ List.of(Field.any("id", orderIds)),
/*fields to remove*/ List.of("pending"))
}
Packages / Modules
-
The
core
module provides the base implementation and can be used from any JVM language.- The
solutions.bitbadger.documents
package contains support types likeConfiguration
andField
. - The
solutions.bitbadger.documents.java
package contains document access functions and serialization config. - The
solutions.bitbadger.documents.java.extensions
package contains extensions on the JDBCConnection
object, callable as extension methods from Kotlin or as static functions from other languages.
- The
-
The
groovy
module packages the extension methods so that Groovy can access them. No other packages will need to be imported; they will show up on anyConnection
instance. -
The
kotlinx
module utilizes the kotlinx-serialization project for its JSON serialization, which requires a different serializer and different function/method signatures (inline fun <reified T> ...
vs.fun <T> ...
).solutions.bitbadger.documents.kotlinx
andsolutions.bitbadger.documents.kotlinx.extensions
packages expose a similar API to theirjava
counterparts, but one designed to be consumed from Kotlin. Generally, document retrieval functions will require a generic parameter instead of aClass<T>
parameter.
-
The
scala
module extendscore
by utilizing Scala's implicitClassTag
s to remove theClass[T]
parameter.solutions.bitbadger.documents.scala
andsolutions.bitbadger.documents.scala.extensions
packages expose the same API as theirjava
counterparts, utilizing Scala collections andOption
s instead of Java collections andOptional
s.
Description
Treat PostgreSQL and SQLite as document stores from Java and Kotlin
https://relationaldocs.bitbadger.solutions/jvm/
v1 (RC 1)
Latest
Languages
Kotlin
45%
Scala
22.9%
Java
17.7%
Groovy
14.4%