Closed
Description
- Node.js Version: v8.9.2
- OS: WIndows 10 (Version 1709 (OS Build 16299.192))
- Scope (install, code, runtime, meta, other?):
- Module (and version) (if relevant):
# I'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: 'https://upload.wikimedia.org/wikipedia/en/5/5e/Gothiccover.png',
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:2316) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): Error: URI does not have hostname, domain name and tld
(node:2316) [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.
my package.json has these modules:
{
"name": "shopping-cart",
"version": "0.0.0",
"private": true,
"scripts": {
"start": "node ./bin/www"
},
"dependencies": {
"body-parser": "~1.18.2",
"cookie-parser": "~1.4.3",
"debug": "~2.6.9",
"express": "~4.15.5",
"express-handlebars": "^3.0.0",
"hbs": "~4.0.1",
"mongoose": "^5.0.7",
"morgan": "~1.9.0",
"serve-favicon": "~2.4.5"
}
}
Metadata
Metadata
Assignees
Labels
No labels