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
coremodule provides the base implementation and can be used from any JVM language.- The 
solutions.bitbadger.documentspackage contains support types likeConfigurationandField. - The 
solutions.bitbadger.documents.javapackage contains document access functions and serialization config. - The 
solutions.bitbadger.documents.java.extensionspackage contains extensions on the JDBCConnectionobject, callable as extension methods from Kotlin or as static functions from other languages. 
 - The 
 - 
The
groovymodule packages the extension methods so that Groovy can access them. No other packages will need to be imported; they will show up on anyConnectioninstance. - 
The
kotlinxmodule 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.kotlinxandsolutions.bitbadger.documents.kotlinx.extensionspackages expose a similar API to theirjavacounterparts, but one designed to be consumed from Kotlin. Generally, document retrieval functions will require a generic parameter instead of aClass<T>parameter.
 - 
The
scalamodule extendscoreby utilizing Scala's implicitClassTags to remove theClass[T]parameter.solutions.bitbadger.documents.scalaandsolutions.bitbadger.documents.scala.extensionspackages expose the same API as theirjavacounterparts, utilizing Scala collections andOptions instead of Java collections andOptionals.
 
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%