{"size": 1505, "ext": "js", "max_stars_repo_path": "routes/update_book_details.js", "max_stars_repo_name": "odeladetunji/quidax_bookstore", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "routes/update_book_details.js", "max_issues_repo_name": "odeladetunji/quidax_bookstore", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "routes/update_book_details.js", "max_forks_repo_name": "odeladetunji/quidax_bookstore", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 32.0212765957, "max_line_length": 92, "alphanum_fraction": 0.5813953488}
const express = require('express');
const app = express.Router();
const modelData = require('../database/models/data');
const validation = require('../validation/validateToken');

app.put("/", validation.validateToken, (request, response) => {
    

    modelData.quidax_books_details.findOne({
        where: {
            id: request.body.id
        }
    }).then(resp => {
        resp.update({
            updated_by: request.body.updated_by,
            deleted: request.body.deleted,
            release_date: request.body.release_date,
            summary: request.body.summary,
            title: request.body.title,
            publisher: request.body.publisher,
            genre: request.body.genre,
            created_date: request.body.create_date,
            created_by: request.body.created_by,
            copies_sold: request.body.copies_sold,
            author: request.body.author
        }).then(result => {
            let responsePayload = {}; 
            responsePayload['body'] = {}
            responsePayload['message'] = 'Book Details Successfully Updated';
            responsePayload['body'] = result;

            return response.send(responsePayload);

        }, (errMsg) => {
            console.log(errMsg)
            return response.status(400).json({ errors: errMsg});
        });
    }, (errMsg) => {
        console.log(errMsg)
        return response.status(400).json({ errors: "A book detail with this id not found"});
    });
    

});

module.exports = app;
