Advertisement
Guest User

Untitled

a guest
Aug 2nd, 2015
510
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.95 KB | None | 0 0
  1. MongoError: exception: After applying the update to the document {_id: ObjectId('55be3c8f79bae4f80c6b17f8') , ...}, the (immutable) field '_id' was found to have been altered to _id: ObjectId('55be5f15ae
  2. 5597401724aab3')
  3.  
  4. xmlFile.product_list.product.forEach(function (product) {
  5.  
  6. var productEntity = new Product({
  7. product_id: parseInt(product.id),
  8. parent_id: parseInt(product.parent_id),
  9. sku: product.sku,
  10. title: product.title,
  11. pricenormal: parseFloat(product.price_normal),
  12. pricewholesale: parseFloat(product.price_wholesale),
  13. pricewholesalelarge: parseFloat(product.price_wholesale_large),
  14. pricesale: parseFloat(product.price_sale),
  15. weight: parseFloat(product.weight),
  16. volume: parseFloat(product.volume),
  17. unittype: product.unit_type,
  18. status: product.status,
  19. datecreating: product.datecreating,
  20. sp: product.sp,
  21. guaranteeext: product.guarantee_ext,
  22. used: product.used,
  23. statusfull: product.status_full,
  24. description: null,
  25. url: null
  26. });
  27. items.push(productEntity);
  28.  
  29. });
  30.  
  31.  
  32. items.forEach(function (product) { //update or create new products
  33.  
  34. Product.findOneAndUpdate({product_id: product.product_id}, product, {upsert: true}, function (err) {
  35. if (err) return updateDBCallback(err);
  36. updateDBCallback(null, 'saved');
  37.  
  38. });
  39.  
  40. });
  41.  
  42. //product._id = mongoose.Types.ObjectId(); //doesnt work
  43. //delete product._id // doesnt delete _id from product
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement