Skip to content

Instantly share code, notes, and snippets.

@zhangcheng
Created January 9, 2013 15:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zhangcheng/4494041 to your computer and use it in GitHub Desktop.
Save zhangcheng/4494041 to your computer and use it in GitHub Desktop.
meteor client side 避免动日期类型
### mongo shell
> db.todos.find({text: 'Ada Lovelace'})
{ "_id" : "fd53324c-412f-49e8-bc12-28aaba5cf878", "hello" : "world", "list_id" : "06ab59ee-cfa0-4469-bd11-8f4077040a06", "shot_at" : ISODate("2013-01-09T15:23:35.662Z"), "tags" : [ "Computer Science" ], "text" : "Ada Lovelace", "timestamp" : 1357743708239 }
> db.todos.update({text: 'Ada Lovelace'}, {$set: {info: {tm: new Date(), name: "a1"}}})
> db.todos.find({text: 'Ada Lovelace'})
{ "_id" : "fd53324c-412f-49e8-bc12-28aaba5cf878", "hello" : "world", "info" : { "tm" : ISODate("2013-01-09T15:26:44.365Z"), "name" : "a1" }, "list_id" : "06ab59ee-cfa0-4469-bd11-8f4077040a06", "shot_at" : ISODate("2013-01-09T15:23:35.662Z"), "tags" : [ "Computer Science" ], "text" : "Ada Lovelace", "timestamp" : 1357743708239 }
### chrome js console
Todos.update({text: 'Ada Lovelace'}, {'$set': {"info.name": "b2"}})
### mongo shell
> db.todos.find({text: 'Ada Lovelace'})
{ "_id" : "fd53324c-412f-49e8-bc12-28aaba5cf878", "hello" : "world", "info" : { "tm" : ISODate("2013-01-09T15:26:44.365Z"), "name" : "b2" }, "list_id" : "06ab59ee-cfa0-4469-bd11-8f4077040a06", "shot_at" : ISODate("2013-01-09T15:23:35.662Z"), "tags" : [ "Computer Science" ], "text" : "Ada Lovelace", "timestamp" : 1357743708239 }
@RemyLiu
Copy link

RemyLiu commented Jan 10, 2013

在mongo shell 里面直接用new Date()可以。但是js层面,new Date()执行后会变成字符串,我现在就是更新的时候不管这个字段。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment