diff --git a/.DS_Store b/.DS_Store index 5008ddf..9226c90 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/app.js b/app.js index 0f34eb0..a9bde9e 100644 --- a/app.js +++ b/app.js @@ -34,7 +34,7 @@ app.get("/test", (req, res) => { app.get("/", async function(req, res) { let objItem = await Item.find({}); - // console.log(objItem); + console.log(objItem, 'first'); res.render("index", { objItem }); @@ -60,20 +60,20 @@ app.set("view engine", "hbs"); // app.use("/users", usersRouter); mongoose.connect( - "mongodb+srv://artem:artem@cluster0-nnm84.mongodb.net/ozonItems", + "mongodb+srv://artem:artem@cluster0-nnm84.mongodb.net/ozon", { useNewUrlParser: true, useUnifiedTopology: true } ); -app.get("/", async function(req, res) { - let objItem = await Item.find({}); - // console.log(objItem); - res.render("index", { - objItem - }); -}); +// app.get("/", async function(req, res) { +// let objItem = await Item.find({}); +// console.log(objItem, 'here'); +// res.render("index", { +// objItem +// }); +// }); // Обработка ошибок. app.use((req, res, next) => { diff --git a/model/itemModel.js b/model/itemModel.js index 280bb7f..c5a34ff 100644 --- a/model/itemModel.js +++ b/model/itemModel.js @@ -11,7 +11,9 @@ const ItemSchema = new Schema({ size: String, cameraResolution: Number, internalMemory: String, - RAM: String + RAM: String, + rating: Number, + color: Array, }); diff --git a/package.json b/package.json index 4060b78..21922b1 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "", "main": "app.js", "scripts": { - "start": "npx nodemon app.js", + "start": "node app.js", "test": "echo \"Error: no test specified\" && exit 1" }, "author": "", diff --git a/seed/seed.js b/seed/seed.js index d0c820e..5cb20fa 100644 --- a/seed/seed.js +++ b/seed/seed.js @@ -1,6 +1,6 @@ const Item = require('../model/itemModel'); const mongoose = require('mongoose'); - +const app = require('../app') async function createUser() { @@ -9,7 +9,7 @@ async function createUser() { let item1 = await Item.create({ img: 'https://cdn1.ozone.ru/multimedia/c1200/1026952828.jpg', - name: 'Смартфон Honor 10 Lite 3/64GB, черный', + name: 'Смартфон Honor 10 Lite 3/64GB', price: 10990, guarantee: '1 год', screenResolution: '2340x1080', @@ -17,12 +17,13 @@ async function createUser() { size: '154.8 x 73.6 x 8', cameraResolution: 13, internalMemory: '64 ГБ', - RAM: '3 ГБ' + color: ["black", "white", "red", "green"], + rating: 2 }); let item2 = await Item.create({ img: 'https://cdn1.ozone.ru/s3/multimedia-z/c1200/6005742539.jpg', - name: 'Смартфон Honor 9X Premium 6/128GB, черный', + name: 'Смартфон Honor 9X Premium 6/128GB', price: 17382, guarantee: 'Нет информации', screenResolution: '2340x1080', @@ -30,12 +31,14 @@ async function createUser() { size: '163.5 × 77.3 × 8.8', cameraResolution: 48, internalMemory: 'Нет информации', - RAM: 'Нет информации' + RAM: 'Нет информации', + color: ["black", "white", "red", "green"], + rating: 3 }); let item3 = await Item.create({ img: 'https://cdn1.ozone.ru/multimedia/c1200/1028043675.jpg', - name: 'Смартфон Honor 10i 4/128GB, черный', + name: 'Смартфон Honor 10i 4/128GB', price: 12990, guarantee: '1 год', screenResolution: '2340x1080', @@ -43,12 +46,14 @@ async function createUser() { size: 'Нет информации', cameraResolution: 24, internalMemory: '128 ГБ', - RAM: '4 ГБ' + RAM: '4 ГБ', + color: ["black", "white", "red", "green"], + rating: 1 }); let item4 = await Item.create({ img: 'https://cdn1.ozone.ru/multimedia/c1200/1034224013.jpg', - name: 'Смартфон Smartisan U3 4/64GB, бежевый', + name: 'Смартфон Smartisan U3 4/64GB', price: 10495, guarantee: 'Нет информации', screenResolution: '2160х1080', @@ -56,7 +61,54 @@ async function createUser() { size: 'Нет информации', cameraResolution: 13, internalMemory: 'Нет информации', - RAM: 'Нет информации' + RAM: 'Нет информации', + color: ["black", "white", "red", "green"], + rating: 5 + }); + + let item5 = await Item.create({ + img: 'https://cdn1.ozone.ru/s3/multimedia-m/c1200/6005039950.jpg', + name: 'Смартфон realme XT 8/128GB', + price: 35000, + guarantee: '3 года', + screenResolution: '2340x1080', + screenDiagonale: '5,99', + size: 'Нет информации', + cameraResolution: 13, + internalMemory: '128 ГБ', + RAM: '8 ГБ', + color: ["black", "white", "red", "green"], + rating: 3 + }); + + let item6 = await Item.create({ + img: 'https://cdn1.ozone.ru/s3/multimedia-s/c1200/6006221044.jpg', + name: 'Смартфон Xiaomi Redmi Note 8T 4/64GB', + price: 25000, + guarantee: '2 года', + screenResolution: '2340x1080', + screenDiagonale: '5,99', + size: 'Нет информации', + cameraResolution: 13, + internalMemory: '512 ГБ', + RAM: '4 ГБ', + color: ["black", "white", "red", "green"], + rating: 5 + }); + + let item6 = await Item.create({ + img: 'https://cdn1.ozone.ru/s3/multimedia-q/c1200/6001501874.jpg', + name: 'Смартфон Xiaomi Redmi Note 7 4/64GB', + price: 12000, + guarantee: '2 года', + screenResolution: '2340x1080', + screenDiagonale: '5,99', + size: 'Нет информации', + cameraResolution: 13, + internalMemory: '64 ГБ', + RAM: '4 ГБ', + color: ["black", "white", "red", "green"], + rating: 4 }); await mongoose.disconnect(); diff --git a/views/index.hbs b/views/index.hbs index d12cb71..8ad4dfd 100644 --- a/views/index.hbs +++ b/views/index.hbs @@ -1,5 +1,5 @@
| # | -|||||
|---|---|---|---|---|---|
| Название | -{{this.name}}> | -{{this.name}} | -{{this.name}} | -{{this.name}} | -{{this.name}} | - - -
| Камера | -{{this.cameraResolution}} | -{{this.cameraResolution}} | -{{this.cameraResolution}} | -{{this.cameraResolution}} | -{{this.cameraResolution}} | - - -
| Цена | -{{this.price}} | -{{this.price}} | -{{this.price}} | -{{this.price}} | -{{this.price}} | - -
| Память | -{{this.internalMemory}} | -{{this.internalMemory}} | -{{this.internalMemory}} | -{{this.internalMemory}} | -{{this.internalMemory}} | - - -
| RAM | -{{this.RAM}} | -{{this.RAM}} | -{{this.RAM}} | -{{this.RAM}} | -{{this.RAM}} | - - -
| Размер | -{{this.size}} | -{{this.size}} | -{{this.size}} | -{{this.size}} | -{{this.size}} | - - -
| Гарантия | -{{this.guarantee}} | -{{this.guarantee}} | -{{this.guarantee}} | -{{this.guarantee}} | -{{this.guarantee}} | - - -
- -
- - --}} + diff --git a/views/layout.hbs b/views/layout.hbs index 45d245b..e3b086f 100644 --- a/views/layout.hbs +++ b/views/layout.hbs @@ -36,7 +36,7 @@ {{{body}}}