Initial Development #1
2
.idea/compiler.xml
generated
2
.idea/compiler.xml
generated
@ -6,6 +6,7 @@
|
|||||||
<sourceOutputDir name="target/generated-sources/annotations" />
|
<sourceOutputDir name="target/generated-sources/annotations" />
|
||||||
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||||
<outputRelativeToContentRoot value="true" />
|
<outputRelativeToContentRoot value="true" />
|
||||||
|
<module name="kotlin" />
|
||||||
<module name="core" />
|
<module name="core" />
|
||||||
<module name="groovy" />
|
<module name="groovy" />
|
||||||
<module name="scala" />
|
<module name="scala" />
|
||||||
@ -19,7 +20,6 @@
|
|||||||
<module name="documents (2)" target="1.5" />
|
<module name="documents (2)" target="1.5" />
|
||||||
<module name="java" target="17" />
|
<module name="java" target="17" />
|
||||||
<module name="jvm" target="11" />
|
<module name="jvm" target="11" />
|
||||||
<module name="kotlin" target="17" />
|
|
||||||
<module name="sqlite" target="1.8" />
|
<module name="sqlite" target="1.8" />
|
||||||
</bytecodeTargetLevel>
|
</bytecodeTargetLevel>
|
||||||
</component>
|
</component>
|
||||||
|
52
README.md
52
README.md
@ -1,3 +1,53 @@
|
|||||||
# solutions.bitbadger.documents
|
# solutions.bitbadger.documents
|
||||||
|
|
||||||
Treat PostgreSQL and SQLite as document stores from Java and Kotlin
|
Treat PostgreSQL and SQLite as document stores from Java, Kotlin, Scala, and Groovy
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
```java
|
||||||
|
// Retrieve (find) all orders (Java)
|
||||||
|
public List<Order> findOrders(Connection conn) {
|
||||||
|
Find.all(/*table name*/ "order", /*type*/ Order.class, conn);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
// 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)
|
||||||
|
)
|
||||||
|
```
|
||||||
|
|
||||||
|
```scala
|
||||||
|
// Delete orders marked as obsolete (Scala)
|
||||||
|
def deleteObsolete(Connection conn):
|
||||||
|
conn.deleteByFields(/*table name*/ "order",
|
||||||
|
/*field criteria*/ Field.equal("obsolete", true) :: Nil)
|
||||||
|
```
|
||||||
|
|
||||||
|
```groovy
|
||||||
|
// 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 like `Configuration` and `Field`.
|
||||||
|
* The `solutions.bitbadger.documents.java` package contains document access functions and serialization config.
|
||||||
|
* The `solutions.bitbadger.documents.java.extensions` package contains extensions on the JDBC `Connection` object, callable as extension methods from Kotlin or as static functions from other languages.
|
||||||
|
|
||||||
|
* 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 any `Connection` 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` and `solutions.bitbadger.documents.kotlinx.extensions` packages expose a similar API to their `java` counterparts, but one designed to be consumed from Kotlin. Generally, document retrieval functions will require a generic parameter instead of a `Class<T>` parameter.
|
||||||
|
|
||||||
|
* The `scala` module extends `core` by utilizing Scala's implicit `ClassTag`s to remove the `Class[T]` parameter.
|
||||||
|
* `solutions.bitbadger.documents.scala` and `solutions.bitbadger.documents.scala.extensions` packages expose the same API as their `java` counterparts, utilizing Scala collections and `Option`s instead of Java collections and `Optional`s.
|
||||||
|
@ -58,7 +58,7 @@
|
|||||||
</execution>
|
</execution>
|
||||||
<execution>
|
<execution>
|
||||||
<id>test-compile</id>
|
<id>test-compile</id>
|
||||||
<phase>test-compile</phase>
|
<phase>process-test-sources</phase>
|
||||||
<goals>
|
<goals>
|
||||||
<goal>test-compile</goal>
|
<goal>test-compile</goal>
|
||||||
</goals>
|
</goals>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user