Skip to content

Commit

Permalink
Fix bug for mongoose issue
Browse files Browse the repository at this point in the history
The new version of mongoose remove its built-in promise, so we replace
method chain with callbacks
  • Loading branch information
gocreating committed Nov 29, 2016
1 parent b4dd883 commit 52cca26
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/server/controllers/todo.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,17 @@ export default {
perPage: 5,
}, handleDbError(res)((page) => {
Todo
.find({})
.sort({ createdAt: 'desc' })
.limit(page.limit)
.skip(page.skip)
.exec(handleDbError(res)((todos) => {
.find({}, null, {
limit: page.limit,
skip: page.skip < 0 ? 0 : page.skip,
sort: { createdAt: 'desc' },
})
.then((todos) => {
res.json({
todos: todos,
page: page,
});
}));
});
}));
},

Expand Down

0 comments on commit 52cca26

Please sign in to comment.