Announcement Announcement Module
Collapse
No announcement yet.
MongoDB update using @Query in repository Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • MongoDB update using @Query in repository

    Hi All,

    I am hoping there is a way to update a property in a mongo document without having to retrieve and save the entire object.

    For example, if I use the Mongo template, I could do:

    Code:
    template.upsert(query(where("_id").is("123asd"), update("lastName", lastName), Person.class);
    This will allow me to update just the last name of the "Person" document without having to retrieve the entire "Person" document and update the object and then save.

    Is there a construct that will allow me to use the repository and do selective updates or do I have to revert to using the mongo template to update a field in the document?

    Is there something like:

    Code:
    @ModifyingQuery
    @Query("{ _id : { $eq : '123asd' }, upsert {'lastName', ?0}}")
    public abstract void updateLastName(String lastName);
    Thanks,
    Tom

  • #2
    Nope, not yet. Feel free to create a JIRA ticket.

    Comment

    Working...
    X