查找兩個(gè)日期之間的對(duì)象MongoDB我一直在MongoDB中存儲(chǔ)tweet,每個(gè)對(duì)象如下所示:{"_id" : ObjectId("4c02c58de500fe1be1000005"),"contributors" : null,"text" : "Hello world","user" : {
"following" : null,
"followers_count" : 5,
"utc_offset" : null,
"location" : "",
"profile_text_color" : "000000",
"friends_count" : 11,
"profile_link_color" : "0000ff",
"verified" : false,
"protected" : false,
"url" : null,
"contributors_enabled" : false,
"created_at" : "Sun May 30 18:47:06 +0000 2010",
"geo_enabled" : false,
"profile_sidebar_border_color" : "87bc44",
"statuses_count" : 13,
"favourites_count" : 0,
"description" : "",
"notifications" : null,
"profile_background_tile" : false,
"lang" : "en",
"id" : 149978111,
"time_zone" : null,
"profile_sidebar_fill_color" : "e0ff92"},"geo" : null,"coordinates" : null,"in_reply_to_user_id" : 149183152,"place" :
null,"created_at" : "Sun May 30 20:07:35 +0000 2010","source" : "web","in_reply_to_status_id" : {
"floatApprox" : 15061797850},"truncated" : false,"favorited" : false,"id" : {
"floatApprox" : 15061838001}如何編寫查詢,以檢查創(chuàng)建at在18:47到19:00之間找到所有物體?是否需要更新文檔,以便以特定格式存儲(chǔ)日期?
3 回答

天涯盡頭無女友
TA貢獻(xiàn)1831條經(jīng)驗(yàn) 獲得超9個(gè)贊
是的,您必須傳遞Javascript日期對(duì)象。 是的,必須是友好的 是的,根據(jù)我的經(jīng)驗(yàn),你需要操作ISO的日期 是的,處理日期通常是一個(gè)乏味的過程,mongo也不例外。
var inputDate = new Date(myDate.toISOString());MyModel.find({ 'date': { $lte: inputDate }})
- 3 回答
- 0 關(guān)注
- 792 瀏覽
添加回答
舉報(bào)
0/150
提交
取消