Kotlin BSON • Multiplatform abstraction for different BSON implementations • opensavvy.ktmongo.bson.types • ObjectId
ObjectId¶
@ExperimentalTime
class ObjectId : Comparable<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¶
ObjectId
¶
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¶
Companion
¶
object Companion
Properties¶
bytes
¶
Generates a byte representation of this ObjectId
instance.
counter
¶
A 3-byte incrementing counter per client-side process, initialized to a random value. Always positive.
hex
¶
Generates a hex representation of this ObjectId
instance.
processId
¶
5-byte random value generated per client-side process.
timestamp
¶
The ObjectId creation timestamp, with a resolution of one second.