Mongodb 春天的梦幻按时间寻找
我有以下查询在mongoDB中工作Mongodb 春天的梦幻按时间寻找,mongodb,spring-boot,mongodb-query,Mongodb,Spring Boot,Mongodb Query,我有以下查询在mongoDB中工作 db.item.find({"startdate":{"$gte" : (new Date(itemDate)).getTime()}}) 其中itemDate是YYYY-MM-DD格式的日期 itemDate="2017-01-01" 现在我想在一个springBoot应用程序中,在一个扩展mongoRepository的类中编写它 我试了一下: `itemRepository.f
db.item.find({"startdate":{"$gte" : (new Date(itemDate)).getTime()}})
其中itemDate是YYYY-MM-DD格式的日期
itemDate="2017-01-01"
现在我想在一个springBoot应用程序中,在一个扩展mongoRepository的类中编写它
我试了一下:
`itemRepository.find({"itemDate":{"$gte" : (new Date(itemDate)).getTime()}})`;
但我甚至不能编译它。
我不知道使用哪种mongoRepository方法。
字段startdate似乎存储为时间戳。MongoTemplate可能更适合您的需要。最好在有像这样更复杂的查询时使用。使用MongoTemplate,您可以这样编写查询:
Query query = Query.query(Criteria.where("startdate").gte(new Date(itemDate).getTime()));
mongoTemplate.find(query, Item.class);