ObjectIdGenerator

An object responsible for generating new ObjectId instances.

This object is similar to Clock: a Clock is a way to generate Instant instances, and services that need to generate instants should receive a clock via dependency injection. Similarly, services that generate IDs should get a generator via dependency injection.

Each collection has its own ObjectIdGenerator instance, set by default by the driver.

Inheritors

Types

Link copied to clipboard
object Companion
Link copied to clipboard
class Default(clock: Clock = Clock.System, random: Random = Random, processId: Long = random.nextLong(0, ObjectId.PROCESS_ID_BOUND)) : ObjectIdGenerator

The default ObjectIdGenerator, implementing the MongoDB ObjectId generation algorithm.

Link copied to clipboard

Hardcoded ObjectId generator with a deterministic input sequence.

Functions

Link copied to clipboard
abstract fun newId(): ObjectId

Creates a new instance of an ObjectId.