MongoDB 里面日期查询的问题
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這種寫法調(diào)通,
測試數(shù)據(jù):
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
}
})
==============
總結
以上是生活随笔為你收集整理的MongoDB 里面日期查询的问题的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 用MySql的查询分析语法explain
- 下一篇: java 短信猫发送短信的方法