Skip to content

[Feature] Allow specifying the return type on Update #343

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jebbench opened this issue May 8, 2020 · 4 comments · Fixed by #345
Closed

[Feature] Allow specifying the return type on Update #343

jebbench opened this issue May 8, 2020 · 4 comments · Fixed by #345
Assignees

Comments

@jebbench
Copy link

jebbench commented May 8, 2020

When you pass the return new/old arguments to the updateDocument(s) method it will cast the result to the same type as the update argument.

I usually use a map to perform the updates as I don't want to provide all of the entities properties but I would like to receive the updated entity back cast to it's type.

Is it possible to add a third argument to the update methods to specify the expected return type?
It would probably make sense to add the same argument to other methods that return the same type they're given such as insert but these aren't currently an issue for me.

@rashtao
Copy link
Collaborator

rashtao commented May 29, 2020

@jebbench I created this PR to address the issue: #345
Can you please check if it solves the problem for you?

@jebbench
Copy link
Author

jebbench commented Jun 3, 2020

The updated interfaces look like exactly what I'm after; I've not tried it in practce though - is there an easy way to do so?

@rashtao
Copy link
Collaborator

rashtao commented Jun 4, 2020

You can checkout the related branch and try testing your use cases.
To try it in external projects you can install it to you local maven repository (mvn install -DskipTests=true -Dgpg.skip). Before this, to avoid overriding maven artifacts, change the version in the pom, to something like: <version>6.6.4-SNAPSHOT-PR345</version>.

@jebbench
Copy link
Author

@rashtao I can confirm this works for me! Cheers for reacting so quickly and for the patience with my slow responses.

getCollection(client)
    .updateDocuments(
        it,
        DocumentUpdateOptions().keepNull(false).mergeObjects(true).returnNew(true),
        clazz
    )
    .await()
    .documents
    .map { it.new }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants