如何格式化mongodb导出的数据

2024-09-28 22:37:39 发布

您现在位置:Python中文网/ 问答频道 /正文

在我的mongodb数据库集合中有一个document,其格式如下:

{
    "_id": {
        "$oid": "18ad45c2c081aa"
    },
    "some_date": "Tue Jan 25 01:41:35 +0000 2018",
    "id": 1077378793470193664
}

但是,当我使用mongoexport导出我的集合时,下载的json文件的文档格式如下:

{  
   "_id":{  
      "$oid":"18ad45c2c081aa"
   },
   "some_date":"Tue Jan 25 01:41:35 +0000 2018",
   "id":{  
      "$numberLong":"1077378793470193664"
   }
}

这是因为

To preserve type information, mongoexport and mongoimport uses the strict mode representation for certain types.

但我需要我的数据和前一种格式完全一样。我在mongodb文档中找不到mongoexporthere的解决方案

如何以与数据库中相同的格式获取导出的数据


Tags: 文件数据文档id数据库jsondatemongodb