Thursday, 1 March 2018

[novice question] I'm hitting an error while running the schema file in MongoDB with Nodejs

'm following Academind's playlist on creating Node.js Shopping Cart and in the Video #4 "Seeding Data" I've created the models for it and then trying to create product-seeder.js file as follows:var Product = require('../models/product'); var mongoose = require('mongoose'); mongoose.connect('localhost:27017/shopping'); var products = [ new Product({ imagePath: 'http://ift.tt/2CRCDQu', title: 'Gothic Video Game', description: 'Awesome Game!!!', price: 10 }), new Product({ and it's details }), ]; var done = 0; for (var i = 0; i < products.length; i++) { products[i].save(); done++; if(done === products.length){ exit(); } } function exit(){ mongoose.disconnect(); }; error regarding the mongodb server(node:9372) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): Error: Invalid schema, expected mongodb or mongodb+srv (node:9372) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. (node:9372) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 3): ValidationError: Product validation failed: description: Path description is required.

Submitted March 01, 2018 at 04:39PM by tapu_buoy

No comments:

Post a Comment