title: How to run a custom mongodb query in spring-boot
body: <p>I have a spring-boot application and I am trying to run this below query using it. </p>
  
  <pre><code>db.userActivity.findAndModify(
  { 
     query: { 'appId' : 1234, 'status' : 0},
     update: { $inc: { 'status': 1 } } 
  });
  </code></pre>
  
  <p>I did try something like this <strong>but it didn't work</strong></p>
  
  <pre><code>public interface UserActivityRepository extends MongoRepository&lt;UserActivity, String&gt; {
  
      /**
       * Find all documents in the database
       * @param appId
       * @param status
       * @return
       */
      @Query("{ 'appId' : ?0, 'status' : ?1}")
      public List&lt;UserActivity&gt; findAllDocuments(long appId, int status);
  
      /**
       * Find all documents by appId whose state is unread
       * and marked them read after reading
       * @param appId
       * @return 
       */
      @Query("db.userActivity.findAndModify({ query: { 'appId' : ?0, 'status' : ?1}, update: { $inc: { 'status': 1 } } })")
      public List&lt;UserActivity&gt; findAndUpdateAllUnreadDocuments(long appId, int status);
  }
  </code></pre>
  
  <p>Could you please tell what I am doing wrong?</p>