Skip to content

update error when use nested properties and setTo #404

@WankkoRee

Description

@WankkoRee

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions