From 485bc9094c6674ff6193ea6ee92baaaa15a0b747 Mon Sep 17 00:00:00 2001 From: Maheshparihar231 Date: Mon, 3 Oct 2022 19:09:22 +0530 Subject: [PATCH] Changes made For the library managment for AWS S3 --- app/config/db.config.js | 2 +- app/controllers/tutorial.controller.js | 25 +++++++++++++++++++++---- app/models/tutorial.model.js | 11 ++++++++--- 3 files changed, 30 insertions(+), 8 deletions(-) diff --git a/app/config/db.config.js b/app/config/db.config.js index fb4130c..e0a28ca 100644 --- a/app/config/db.config.js +++ b/app/config/db.config.js @@ -1,3 +1,3 @@ module.exports = { - url: "mongodb://localhost:27017/bezkoder_db" + url: "mongodb://localhost:27017/Books" }; diff --git a/app/controllers/tutorial.controller.js b/app/controllers/tutorial.controller.js index ca7d245..a00785d 100644 --- a/app/controllers/tutorial.controller.js +++ b/app/controllers/tutorial.controller.js @@ -4,18 +4,35 @@ const Tutorial = db.tutorials; // Create and Save a new Tutorial exports.create = (req, res) => { // Validate request - if (!req.body.title) { + if (!req.body.bookid) { res.status(400).send({ message: "Content can not be empty!" }); return; } // Create a Tutorial const tutorial = new Tutorial({ - title: req.body.title, - description: req.body.description, - published: req.body.published ? req.body.published : false + name: req.body.name, + desc: req.body.desc, + page: req.body.page, + tag: req.body.tag, + author: req.body.author, + bucketid: req.body.bucketid, + thumb: req.body.thumb, + bookid: req.body.bookid }); + // { + // title: String, + // desc: String, + // page : String, + // tag: String, + // author: String, + // bucketid: String, + // thumb: String, + // bookid: String + // } + + // Save Tutorial in the database tutorial .save(tutorial) diff --git a/app/models/tutorial.model.js b/app/models/tutorial.model.js index ed90dce..1da3b71 100644 --- a/app/models/tutorial.model.js +++ b/app/models/tutorial.model.js @@ -1,9 +1,14 @@ module.exports = mongoose => { var schema = mongoose.Schema( { - title: String, - description: String, - published: Boolean + name: String, + desc: String, + page : String, + tag: String, + author: String, + bucketid: String, + thumb: String, + bookid: String }, { timestamps: true } );