Results 1 to 2 of 2

Thread: MongoDB update using @Query in repository

Hybrid View

  1. #1

    Question 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. #2
    Join Date
    Apr 2006
    Location
    Dresden, Germany
    Posts
    483

    Default

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

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •