Skip to content

BsonArray

Implementation of opensavvy.ktmongo.bson.BsonArray based on the official MongoDB drivers.

To create instances of this class, see [`BsonFactory`](../../../bson/opensavvy.ktmongo.bson/-bson-factory/index.md).

<blockquote markdown>

This page describes the BSON implementation based on the official MongoDB drivers. To learn more about the general BSON operations, see [`opensavvy.ktmongo.bson.BsonArray`](../../../bson/opensavvy.ktmongo.bson/-bson-array/index.md).


</blockquote>
### Navigating BSON types
This interface is part of the BSON trinity:

 - [`BsonDocument`](../-bson-document/index.md) represents an entire BSON document.


 - [`BsonArray`](index.md) represents an array of BSON values.


 - [`BsonValue`](../-bson-value/index.md) represents a single value in isolation.


### Usage
```kotlin
val bson: BsonArray = …

for (element in bson) {
    println("Element: $element")
}
```

Implementation of a KtMongo opensavvy.ktmongo.bson.BsonArray that wraps a org.bson.BsonArray.

To create an instance of this class, see BsonFactory.readArray.

Types

Serializer

expect object Serializer : KSerializer<BsonArray> 

actual object Serializer : KSerializer<BsonArray> 

Serializer for the official opensavvy.ktmongo.bson.official.BsonArray implementation.

Properties

factory

expect open override val factory: BsonFactory

actual open override val factory: BsonFactory

indices

open val indices: IntRange
open val indices: IntRange

lastIndex

open val lastIndex: Int
open val lastIndex: Int

raw

val raw: BsonArray

size

abstract val size: Int
open override val size: Int

Functions

asIterable

expect open override fun asIterable(): Iterable<BsonValue>

actual open override fun asIterable(): Iterable<BsonValue>

asList

expect open override fun asList(): List<BsonValue>

actual open override fun asList(): List<BsonValue>

asSequence

expect open override fun asSequence(): Sequence<BsonValue>

actual open override fun asSequence(): Sequence<BsonValue>

asValue

expect open override fun asValue(): BsonValue

actual open override fun asValue(): BsonValue

decode

@LowLevelApi
abstract fun <T> decode(type: KType): T
@LowLevelApi
open override fun <T> decode(type: KType): T

decodeElements

@LowLevelApi
open fun <T> decodeElements(type: KType): List<T>
@LowLevelApi
open fun <T> decodeElements(type: KType): List<T>

equals

open operator override fun equals(other: Any?): Boolean

get

expect open operator override fun get(index: Int): BsonValue?

actual open operator override fun get(index: Int): BsonValue?

hashCode

open override fun hashCode(): Int

isEmpty

open fun isEmpty(): Boolean
open override fun isEmpty(): Boolean

isNotEmpty

open fun isNotEmpty(): Boolean
open fun isNotEmpty(): Boolean

iterator

expect open operator override fun iterator(): Iterator<BsonValue>

actual open operator override fun iterator(): Iterator<BsonValue>

toString

abstract override fun toString(): String
open override fun toString(): String

withIndex

expect open override fun withIndex(): Iterable<IndexedValue<BsonValue>>

actual open override fun withIndex(): Iterable<IndexedValue<BsonValue>>