Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 8191ce9

Browse files
Added id to responses.
1 parent fa1b035 commit 8191ce9

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

‎controllers/BookController.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ mongoose.set("useFindAndModify", false);
88

99
// Book Schema
1010
function BookData(data) {
11+
this.id = data._id;
1112
this.title= data.title;
1213
this.description = data.description;
1314
this.isbn = data.isbn;
@@ -23,7 +24,7 @@ exports.bookList = [
2324
auth,
2425
function (req, res) {
2526
try {
26-
Book.find({user: req.user._id},"title description isbn createdAt").then((books)=>{
27+
Book.find({user: req.user._id},"_id title description isbn createdAt").then((books)=>{
2728
if(books.length > 0){
2829
return apiResponse.successResponseWithData(res, "Operation success", books);
2930
}else{
@@ -51,7 +52,7 @@ exports.bookDetail = [
5152
return apiResponse.successResponseWithData(res, "Operation success", {});
5253
}
5354
try {
54-
Book.findOne({_id: req.params.id,user: req.user._id},"title description isbn createdAt").then((book)=>{
55+
Book.findOne({_id: req.params.id,user: req.user._id},"_id title description isbn createdAt").then((book)=>{
5556
if(book !== null){
5657
let bookData = new BookData(book);
5758
return apiResponse.successResponseWithData(res, "Operation success", bookData);

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /