IT男网站建设,网站怎么看被百度收录,WordPress网站积分系统,wordpress内页不收录与HibernateRepository类似#xff0c;通过继承MongoRepository接口#xff0c;我们可以非常方便地实现对一个对象的增删改查#xff0c;要使用Repository的功能#xff0c;先继承MongoRepository接口#xff0c;其中T为仓库保存的bean类#xff0c;TD为该bean的唯一标识…与HibernateRepository类似通过继承MongoRepository接口我们可以非常方便地实现对一个对象的增删改查要使用Repository的功能先继承MongoRepository接口其中T为仓库保存的bean类TD为该bean的唯一标识的类型一般为ObjectId。之后在service中注入该接口就可以使用无需实现里面的方法spring会根据定义的规则自动生成。下面是支持的查询类型每三条数据分别对应(方法后缀方法例子MongoDB原生查询语句)GreaterThan(大于)findByAgeGreaterThan(int age){age : {$gt : age}}LessThan(小于)findByAgeLessThan(int age){age : {$lt : age}}Between(在...之间)findByAgeBetween(int from, int to){age : {$gt : from, $lt : to}}IsNotNull, NotNull(是否非空)findByFirstnameNotNull(){age : {$ne : null}}IsNull, Null(是否为空)findByFirstnameNull(){age : null}Like(模糊查询)findByFirstnameLike(String name){age : age} ( age as regex)(No keyword) findByFirstname(String name){age : name}Not(不包含)findByFirstnameNot(String name){age : {$ne : name}}Near(查询地理位置相近的)findByLocationNear(Point point){location : {$near : [x,y]}}Within(在地理位置范围内的)findByLocationWithin(Circle circle){location : {$within : {$center : [ [x, y], distance]}}}Within(在地理位置范围内的)findByLocationWithin(Box box){location : {$within : {$box : [ [x1, y1], x2, y2]}}}Query(value{ name:{$regex:?2,$options:i}, sales:{$gte:?1,$lte:?2}},fields{ name : 1, age : 1})public Page findByNameAndAgeRange(String name,double ageFrom,double ageTo,Pageable page);查询发生时间是2016年之后的 db.station_evaluation.find({currenttime:{$gt:new Date(2016-12-12 12:12:12)}});查询经纬度符合条件的 db.station_evaluation.find({currenttime:{$gt:new Date(2016-12-12 12:12:12)},latitude : 22.560890570746526});查询满足发生时间之后并且该字段一定存在的 db.station_evaluation.find({currenttime:{$gt:new Date(2016-12-12 12:12:12)},currenttime : {$exists:1}});