gpt4 book ai didi

mongodb - 使用 mongoimport 将日期(ISODate)导入 MongoDB

转载 作者:IT老高 更新时间:2023-10-28 13:18:10 25 4
gpt4 key购买 nike

我有这个 MongoDB 文档。在 JSON 中:

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

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

这是 MongoDB shell 通知:

Failed: error unmarshaling bytes on document #1: unexpected ISODateformat

最佳答案

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

任一

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

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

希望对你有帮助

关于mongodb - 使用 mongoimport 将日期(ISODate)导入 MongoDB,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33107278/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com