【发布时间】:2015-08-04 19:46:01
【问题描述】:
我有status 集合,其中有四个字段abc, xyz, status, time
我想为下面的 MySql 查询创建 MongoDB 查询:
select * from status where abc = false and xyz = true and (status = pending or (status = inprogress and time = "2015-08-04"))
基本上status 可以是pending 或inprogress,但如果是inprogress,则必须比较time。
我尝试在 MongodDB 下创建查询,但没有成功
db.status.find
{
"abc" : false ,
"xyz" : true ,
"status" : "pending" ,
"$and" : [
{ "status" : "inprogress"} ,
{ "time" : { "$eq" : { "$date" : "2015-08-04"}}}
]
}
我正在使用 Spring MongoDB,如果有人可以指导我如何在 Spring Data MongoDb 中创建它,我将不胜感激。
谢谢
【问题讨论】:
标签: mongodb spring-data mongodb-query spring-data-mongodb