ObjectId

A 12-bytes identifier for MongoDB objects.

This class allows accessing all fields of an ObjectId as well as constructing instances from existing data. However, it doesn't provide a way to generate new randomized ObjectId instances (as that depends on the database configuration). To do so, see opensavvy.ktmongo.bson.BsonContext.newId.

Constructors

Link copied to clipboard
constructor(timestamp: Instant, processId: Long, counter: Int)

Constructs a new ObjectId from its different components.

constructor(bytes: ByteArray)

Constructs a new ObjectId by reading a byte array.

constructor(hex: String)

Constructs a new ObjectId by reading a hexadecimal representation.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

Generates a byte representation of this ObjectId instance.

Link copied to clipboard

A 3-byte incrementing counter per client-side process, initialized to a random value. Always positive.

Link copied to clipboard
val hex: String

Generates a hex representation of this ObjectId instance.

Link copied to clipboard

5-byte random value generated per client-side process.

Link copied to clipboard

The ObjectId creation timestamp, with a resolution of one second.

Functions

Link copied to clipboard
operator fun compareTo(other: Instant): Int
open operator override fun compareTo(other: ObjectId): Int
Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
open override fun toString(): String