AsyncMongoDBStorage

data class AsyncMongoDBStorage<T>(val mongoDBConnection: MongoDBConnection, val databaseName: String, val collectionName: String, val serializer: Serializer<T, String>) : AsyncStorage<String, T, String>

AsyncStorage implementation via file + text strings.

This method was based from roby2014 - uni-projects/TDS

Parameters

T

Type of the domain entity

mongoDBConnection

MongoDB connection information

databaseName

Name of the MongoDB database

collectionName

Name of the MongoDB collection

Constructors

Link copied to clipboard
constructor(mongoDBConnection: MongoDBConnection, databaseName: String, collectionName: String, serializer: Serializer<T, String>)

Properties

Link copied to clipboard
private val collectionName: String
Link copied to clipboard
private val databaseName: String
Link copied to clipboard
Link copied to clipboard
open override val serializer: Serializer<T, String>

The serializer responsible for converting entities to/from the storage format.

Link copied to clipboard
private val storage: MongoDBStorage<T>

Functions

Link copied to clipboard
open suspend override fun close()

Closes the async MongoDB storage, releasing any held resources.

Link copied to clipboard
open suspend override fun delete(id: String)

Deletes an entity from async MongoDB storage by its identifier.

Link copied to clipboard
open suspend override fun lastModified(id: String): Long?

Gets the last modification timestamp for an entity in async MongoDB storage.

Link copied to clipboard
open suspend override fun load(id: String): T?

Retrieves an entity from async MongoDB storage by its identifier.

Link copied to clipboard
open suspend override fun loadAllIds(): List<String>

Loads all entity identifiers currently stored in this async MongoDB storage.

Link copied to clipboard
open suspend override fun new(id: String, factory: () -> T): T

Creates a new entity in async MongoDB storage with the given identifier.

Link copied to clipboard
open suspend override fun save(id: String, obj: T)

Saves (persists) an entity in async MongoDB storage under the given identifier.