Skip to content

MongoDB request DSLopensavvy.ktmongo.dsl.aggregation.operatorsTypeValueOperatorstoUuid

toUuid

open fun <R : Any> Value<R, *>.toUuid(): Value<R, >

Converts a string value to a Uuid (BsonType.BinaryData).

Example

class User(
    val _id: ObjectId,
    val eventId: Uuid,
)

// Convert old 'eventId' data which was incorrectly created as strings
users.updateManyWithPipeline {
    set {
        User::eventId set of(User::eventId).toUuid()
    }
}

External resources

See also