将嵌套 JSON 文件转换并存储为 MongoDB 文档的最佳实践是什么?
我有一个巨大(约1.8GB)的JSON文件,我的目标是在Express应用中使用的数据。加载JSON文件本身是不可行的,因为节点将导入到512MB。我是MongoDB的新手(通常是数据库),因此避免使用它们,但是,此问题似乎必须使用数据库来解决它。
我想知道是否有一种方法可以将我的JSON文件(包括5个级别嵌套的数据)转换为MongoDB文档,我可以使用Mongoose从服务器查询。
I have a huge (approx. 1.8gb) JSON file, the data of which I aim to use in an Express app. Loading the JSON file itself is infeasible as Node limits imports to 512mb. I am new to MongoDB (and databases in general) and thus have avoided using them so far, however, this issue appears as though it must be solved using a database.
I am wondering if there is a method by which I can convert my JSON file (which includes data nested up to 5 levels) into a MongoDB document that I can query from my server using Mongoose.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我设法通过进一步搜索解决了这个问题。将最大对象转换为数组(创建一个在MongoDB中的16MB限制硬性编码下的2000个较小对象的数组)之后,我使用了 mongoimport 命令将JSON转换为文档。
I managed to resolve this issue through further searching. After converting the largest object into an array (creating an array of 2000 smaller objects that were under the 16mb limit hard coded in MongoDB), I used the mongoimport command to convert the JSON into documents.