mongodb 命令行插入date类型报错
伊谢尔伦
伊谢尔伦 2017-04-25 09:02:49
0
1
764

如何在命令行插入当前时间的数据

db.favors.insert({"xsId":ObjectId("5551335b322ae4de5a53cfa4”), "feedId" : ObjectId("555023342284ba365a652a2f"), "feedUserId" : ObjectId("554f2a9a0c02c2fa51456706"), "hasRead" : true, "date" : date.now()})

报错:2015-05-13T11:48:48.210+0800 SyntaxError: Unexpected identifier

db.favors.insert({"xsId":ObjectId("5551335b322ae4de5a53cfa4”), "feedId" : ObjectId("555023342284ba365a652a2f"), "feedUserId" : ObjectId("554f2a9a0c02c2fa51456706"), "hasRead" : true, "date" : ISODate("2015-05-11T12:49:46.121Z")})

报错:2015-05-13T11:52:40.841+0800 SyntaxError: Unexpected identifier

急急急,谢谢!

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

reply all(1)
伊谢尔伦
db.favors.insert({"xsId":ObjectId("5551335b322ae4de5a53cfa4”), "feedId" : ObjectId("555023342284ba365a652a2f"), "feedUserId" : ObjectId("554f2a9a0c02c2fa51456706"), "hasRead" : true, "date" : date.now()})

The first ObjectId("5551335b322ae4de5a53cfa4”) uses Chinese quotation marks;
I don’t know your mongodb什么版本,date.now()是不合法的,可以使用Date()wait

Reference
http://www.cnblogs.com/yuechaotian/archive/2013/02/02/2889824.html

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template