Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/config/db.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
url: "mongodb://localhost:27017/bezkoder_db"
url: "mongodb://localhost:27017/Books"
};
25 changes: 21 additions & 4 deletions app/controllers/tutorial.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 8 additions & 3 deletions app/models/tutorial.model.js
Original file line number Diff line number Diff line change
@@ -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 }
);
Expand Down