Created
January 9, 2013 15:31
-
-
Save zhangcheng/4494041 to your computer and use it in GitHub Desktop.
meteor client side 避免动日期类型
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### 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 } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
在mongo shell 里面直接用new Date()可以。但是js层面,new Date()执行后会变成字符串,我现在就是更新的时候不管这个字段。