您的位置:首页 > 数据库 > Mongodb

MongoDB 里面日期查询的问题

2014-07-04 18:12 148 查看
http://www.v2ex.com/t/80624

问题:

原生控制台查不到结果,用Java驱动可以。MongoDB shell version: 2.4.6

具体情况是:

DB:ecommerce, Collection为products,

1.shell命令查不出来结果:

use ecommerce

db.products.find({ "manufacture_details.release_date" : { "$gte" : { "$date" : "2012-05-17T08:14:15.000Z"}}});

2.但是用Java MongoDB Driver 查询,就可以出来,

trace info 显示:find: ecommerce.products { "manufacture_details.release_date" : { "$gte" : { "$date" : "2012-05-17T08:14:15.000Z"}}}

可以查到结果。

3. 用 这种shell命令可以查询到结果:

use ecommerce

db.products.find({"manufacture_details.release_date": {"$gte": new ISODate("2012-05-17 08:14:15.656")}});

但是本人不需要3这种写法,想把1这种写法调通,

测试数据:

mongo

use ecommerce

db.products.insert({

sku: "111445GB3",

title: "Simsong One mobile phone",

description: "The greatest Onedroid phone on the market .....",

manufacture_details: {

model_number: "A123X",

release_date: new ISODate("2012-05-17T08:14:15.656Z")

},

shipping_details: {

weight: 350,

width: 10,

height: 10,

depth: 1

},

quantity: 99,

pricing: {

price: 1000

}

})

==============
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: