Skip to content

BsonType

The different data types supported in BSON documents.

Note that the BSON type is available as the property code. The property <strong>ordinal</strong> is meaningless on this type, and may change over time.

External resources

Entries

Double

A 64-bit floating-point number, represented by the Kotlin class kotlin.Double.

String

A UTF-8 encoded string, represented by the Kotlin class kotlin.String.

Document

An arbitrary document, represented by the Kotlin interface Bson.

Array

An array of arbitrary values, represented by the Kotlin interface BsonArray.

BinaryData

An arbitrary binary block.

Undefined

The undefined value.

ObjectId

A 12-bytes, time-sorted unique identifier for documents, represented by the Kotlin class ObjectId.

Boolean

A boolean value, represented by the Kotlin class kotlin.Boolean.

Datetime

A date and time in UTC, represented by the Kotlin class kotlin.time.Instant.

Null

The null value.

RegExp

A MongoDB regular expression.

DBPointer

A reference to a document in another collection.

JavaScript

A string of JavaScript code.

Symbol

JavaScriptWithScope

A string of JavaScript code, accompanied by a document containing variables.

Int32

A 32-bit signed integer, represented by the Kotlin class kotlin.Int.

Timestamp

A special type used in MongoDB logs, represented by the Kotlin class Timestamp. In most situations, users should use Datetime instead.

Int64

A 64-bit signed integer, represented by the Kotlin class kotlin.Long.

Decimal128

A 128-bit floating-point number.

MinKey

A special value containing the minimum possible value.

MaxKey

A special value containing the maximum possible value.

Types

Companion

object Companion

Properties

code

val code: Byte

The byte identifier for this particular type.

Guaranteed to be in the range -1 (MinKey) to 127 (MaxKey).

entries

Returns a representation of an immutable list of all enum entries, in the order they're declared.

This method may be used to iterate over the enum entries.

name

expect val name: String

ordinal

expect val ordinal: Int

Functions

valueOf

fun valueOf(value: String): BsonType

Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

Throws

IllegalArgumentException

if this enum type has no constant with the specified name

values

Returns an array containing the constants of this enum type, in the order they're declared.

This method may be used to iterate over the constants.