Answer the question
In order to leave comments, you need to log in
Two questions of node.js code in which I fill the database with goods?
There is such a node.js code of two files with which I fill the database with goods.
the file in which I create the model:
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var schema = new Schema({
imagePath: {type: String, required: true},
title: {type: String, required: true},
description: {type: String, required: true},
price: {type: Number, required: true}
});
var schema = new Schema
var schema = new Schema?
var Product = require('../models/product');
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({
imagePath: 'http://eu.blizzard.com/static/_images/games/wow/wallpapers/wall2/wall2-1440x900.jpg',
title: 'World of Warcraft Video Game',
description: 'Also awesome? But of course it was better in vanilla ...',
price: 20
}),
new Product({
imagePath: 'https://support.activision.com/servlet/servlet.FileDownload?file=00PU000000Rq6tz',
title: 'Call of Duty Video Game',
description: 'Meh ... nah, it\'s okay I guess',
price: 40
})
var products = [];
Answer the question
In order to leave comments, you need to log in
All that comes with new is the creation of a new object (class instance). Accordingly, new Product - creation of a new Product object. It turns out that products is an array of Product objects.
var schema = new Schema - similarly, creating an instance of the Schema class.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question