Skip to content

Instantly share code, notes, and snippets.

@pszalawinski
Created April 27, 2020 07:28
Show Gist options
  • Save pszalawinski/69d6f4e711a069006004f296559368b8 to your computer and use it in GitHub Desktop.
Save pszalawinski/69d6f4e711a069006004f296559368b8 to your computer and use it in GitHub Desktop.
Query for MongoDB in Spring app #mongodb
import org.springframework.data.mongodb.repository.Query;
@Repository
public interface BookRepository extends MongoRepository<Book, Integer> {
@Query("{'author' : ?0}") //import org.springframework.data.mongodb.repository.Query;
List<Book> findByAuthor(String author);
}
// documentation: https://docs.spring.io/spring-data/mongodb/docs/current/reference/html/#mongo.repositories
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment