Litote/kmongo

update error when use nested properties and `setTo`

WankkoRee opened this issue · 0 comments

follow the docs: https://litote.org/kmongo/typed-queries/#update, i write these code:

data class Parent (
    val child Child,
) {
    data class Child (
        val name String,
    )
}

col.updateOne(..., Parent::child / Parent.Child::name setTo "test")// code 1.
col.updateOne(..., (Parent::child / Parent.Child::name) setTo "test")// code 2.
col.updateOne(..., (Parent::child / Parent.Child::name).setTo("test"))// code 3.
col.updateOne(..., set(Parent::child / Parent.Child::name setTo "test"))// code 4.
col.updateOne(..., setValue(Parent::child / Parent.Child::name, "test"))// code 5.

if use code 1/2/3, the docs will be:

{
    "child": {
        "name": ""
    },
    "property": "$child.name",
    "value": "test"
}

if use code 4/5, the docs will be:

{
    "child": {
        "name": "test"
    }
}

so if use setTo with nested properties, i also need to use set?