我有这个MongoDB文件.在JSON中:

{
"attString":"hello World0",
"attInt":0,
"attDate":new Date("1990-7-20")
 }
        

如何使用mongoimport将此文档导入MongoDB?attDate字段有问题.

这里是MongoDBshell 通知:

失败:在文档上解组字节时出错#1:意外的ISODate

推荐答案

您必须更改JSON中的日期格式

Either

{"attString":"hello World0","attInt":0,"attDate":ISODate("2013-11-20T23:32:18Z")}

OR

{"attString":"hello World0","attInt":0,"attDate":{"$date":"2013-11-20T23:32:18Z"}} 

希望能有所帮助

Mongodb相关问答推荐

使用mongosh将大型json文件插入到mongo集合中

如何将空值单独分组?

从MongoDB中的嵌套数组中提取找到的值及其索引

Mongo按最大分组排序

我可以在 MongoDB 中将字段值设置为对象键吗?

定期自动轮换 MongoDb 集合

根据聚合管道MongoDB Atlas触发器中的条件更新多个字段

mongodb - 查找包含至少 3 个填充数组的记录

更新 mongodb 文档中的特定字段

SELECT 字段 AS `anothername` 的 mongodb 等效项

如何使用 C# MongoDB 驱动程序检索字段子集?

使用管道聚合的 Spring Data MongoDB 查找

适用于 Windows 10 64 位的 MongoDB 下载

如何使用 MongoDB 建模 likes投票系统

MongoDB - 文件大小巨大且不断增长

Mongodb错误:The positional operator did not find the match needed from the query

MongoDB 中的多个 $inc 更新

如何判断 MongoDB 中是否存在字段?

MongoDB 和 Robomongo: Can't connect (authentication)

聚合 $lookup 匹配管道中文档的总大小超过最大文档大小