basir / mern-amazona

Build Ecommerce Like Amazon By MERN Stack
https://www.youtube.com/watch?v=ZjwBs3n7waY&list=PLeh2GWv22bmSQ9oBSYTd469_AQjPGpzyv
325 stars 242 forks source link

Video-20-Seed-Sample-Products function depreciation issue #27

Open Anurag13975 opened 7 months ago

Anurag13975 commented 7 months ago

there is a minor code issue of function depreciation that might cause an issue in prodcution.

In your code , there is a file named seedRoutes.js. in that file there is a line of code written as below: await Product.remove({});

In new mongoose versions, document.remove() is deprecated. Replace remove() with deleteOne() or deleteMany().

here we should use deleteMany() function. Thus change this line to the new one

await ProductCollection.deleteMany({});