【问题标题】:Mongo not creating all docs in array and not giving errorsMongo没有在数组中创建所有文档并且没有给出错误
【发布时间】:2022-10-21 05:18:46
【问题描述】:

我有一长串要创建的文档。当我创建它们时,我没有收到任何错误。

const docsJson =[some array of json of docs to create]
 
const orders = await MySchema.create(ordersJSON);
// orders.length returns the same number of docs as  docsJson

但是当我搜索新文档时,只创建了一些。


const actualOrdersCreated = await MySchema.find({ _id: { $in: orders.map((p) => p._id) } });
// actualOrdersCreated.length returns less docs than in docsJson

这是什么原因造成的?

【问题讨论】:

    标签: javascript mongodb mongoose mongodb-query


    【解决方案1】:

    我相信这个问题是由于jsonDocs 的大尺寸造成的。

    我有一些对象的字段具有非常大的 base64 图像字符串。这些是占位符,应该替换为图像的 http url。

    删除 base64 字符串后,我就可以上传文档了。

    【讨论】:

      猜你喜欢
      • 2012-11-13
      • 2019-07-27
      • 1970-01-01
      • 2022-01-02
      • 1970-01-01
      • 2015-12-17
      • 1970-01-01
      • 2015-03-16
      • 1970-01-01
      相关资源
      最近更新 更多