node.js mongodb .. the (immutable) field '_id' was found to have been altered

前端 未结 3 364
时光说笑
时光说笑 2020-12-31 00:08

I have some problem when I try to upsert my object with new ones(parsed from xml file),but I got the following error:

 MongoError: exception: After applying         


        
3条回答
  •  情深已故
    2020-12-31 00:58

    try to use

    const product = productEntity.toObject();
    ...
    delete product._id;
    ...
    Product.findOneAndUpdate({product_id: product.product_id}, product)
    

提交回复
热议问题