kotlin-datastore / org.khanacademy.datastore

Package org.khanacademy.datastore

Types

Datastore

class Datastore

Main implementation for interacting with the datastore.

DatastoreBackend

interface DatastoreBackend

Wrapper for datastore access that indicates the applicable environment.

DatastoreEnv

enum class DatastoreEnv

Environment to which a given DatastoreBackend applies.

DatastoreEnvWithProject

data class DatastoreEnvWithProject

Combination of an environment and a Google cloud project name.

GoogleCloudDatastoreBackend

class GoogleCloudDatastoreBackend : DatastoreBackend

DatastoreBackend using the google-cloud-java client library for datastore.

TransactionOptions

data class TransactionOptions

Type Aliases

DatastoreKey

typealias DatastoreKey = <ERROR CLASS>

Properties

DB

val DB: Datastore

Primary external-facing API for interacting with the datastore.

Functions

get

fun <T : Keyed<T>> Datastore.get(key: Key<T>): T?

Synchronous get by key of an object from the datastore.

getAsync

fun <T : Keyed<T>> Datastore.getAsync(key: Key<T>): <ERROR CLASS><T?>

Asynchronous get by key of an object from the datastore.

inTransaction

fun Datastore.inTransaction(): Boolean

initializeEnvAndProject

fun initializeEnvAndProject(env: DatastoreEnv, project: String): Unit

Manually initialize the datastore environment.

put

fun <T : Keyed<T>> Datastore.put(modelInstance: Keyed<T>): Key<T>

Synchronous put of an object to the datastore.

putAsync

fun <T : Keyed<T>> Datastore.putAsync(modelInstance: Keyed<T>): <ERROR CLASS><Key<T>>

Asynchronous put of an object to the datastore.

toDatastoreEntity

fun Keyed<*>.toDatastoreEntity(): <ERROR CLASS>

toDatastoreKey

fun Key<*>.toDatastoreKey(): <ERROR CLASS>

Convert our abstract keys to the Google cloud datastore key class.

toKey

fun <T : Keyed<T>> <ERROR CLASS>.toKey(): Key<T>

Convert a Google cloud datstore key to our abstract key class.

toTypedModel

fun <T : Keyed<T>> <ERROR CLASS>.toTypedModel(tRef: KClass<T>): T

Convert a Google cloud datastore entity to one of our model classes.

transactional

fun <T> Datastore.transactional(options: TransactionOptions, block: Datastore.() -> T): T

Run a function, with all contained datastore operations transactional.

fun <T> Datastore.transactional(block: Datastore.() -> T): T

Run datastore operations in a transaction with default options.