Painless Firebase Object Mapper that was developed with Kotlin in mind.
We rely on the Kotlin Serialization compiler plugin to generate the De-/Serialization code during compile time, which removes the need for expensive reflection calls.
This repository currently resides on the GitHub Packages Registry, which only allows authenticated downloads. For this you need to create a token with at least the read:packages permission from here.
dependencyResolutionManagement {
repositories {
maven {
setUrl("https://maven.pkg.github.com/sipgate/federmappe")
credentials {
username = "your github username"
password = "a personal token with read:packages permission"
}
}
}
// …
}
Once the Repository is set up, you can add the dependency to your module:
dependencies {
implementation("de.sipgate:federmappe.firestore:0.0.23")
}
dependencies {
implementation("de.sipgate:federmappe.realtimedb:0.0.23")
}
enum class Universe {
@SerialName("starwars") StarWars,
@SerialName("startrek") StarTrek
}
@Serializable
data class Spaceship(
val name: String,
@SerialName("max_occupants")
val maxOccupants: Long,
val universe: Universe? = null,
val hasWeapons: Boolean = false
)
val voyager = firestore.collection("spaceships")
.document("NCC-74656")
.get()
.await()
.toObject<Spaceship> { ex ->
// do your exception handling here
}
The unit tests ship with everything needed to run.
./gradlew test
For the integration tests a running Firebase Emulator needs to be present.
Once installed, start the tests (together with the emulators) using:
firebase emulators:exec --project demo-test --only database,firestore './gradlew pixel2api30Check --no-parallel'
Alternatively during development the emulator can be started persistently in the background for the tests to be run against:
firebase emulators:start --project demo-test --only database,firestore
This lib is used in production and works for most of our cases (Primitives, Lists, Nested Types, Sealed Classes, …). If you miss any functionality or find a bug feel free to drop us an Issue. No promises though.