Spring Data MongoDB
3.1生成的查询方法(Generated Query Methods)
我们将通过探索findBy类型的查询来简单地开始 - 在这种情况下,通过名称查找:
List<User> findByName(String name);
3.2 StartingWith and endingWith.
List<User> users = userRepository.findByNameStartingWith("A"); List<User> users = userRepository.findByNameEndingWith("c");
3.3 Between
类似于2.3,这将返回年龄在ageGT和ageLT之间的所有用户:
List<User> findByAgeBetween(int ageGT, int ageLT); List<User> users = userRepository.findByAgeBetween(20, 50);
in and
public interface DetailSkuRepository extends MongoRepository<DetailSku, String> { List<DetailSku> findBySkuInAndIsdel(List<String> skus,Integer state); }
参考:https://www.cnblogs.com/xiaoqi/p/queries-in-spring-data-mongodb.html
原文地址:https://www.cnblogs.com/lyon91/p/10337998.html
时间: 2024-10-06 06:57:58