Skip to content

Commit 52cca26

Browse files
committed
Fix bug for mongoose issue
The new version of mongoose remove its built-in promise, so we replace method chain with callbacks
1 parent b4dd883 commit 52cca26

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/server/controllers/todo.js

+7-6
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,17 @@ export default {
1010
perPage: 5,
1111
}, handleDbError(res)((page) => {
1212
Todo
13-
.find({})
14-
.sort({ createdAt: 'desc' })
15-
.limit(page.limit)
16-
.skip(page.skip)
17-
.exec(handleDbError(res)((todos) => {
13+
.find({}, null, {
14+
limit: page.limit,
15+
skip: page.skip < 0 ? 0 : page.skip,
16+
sort: { createdAt: 'desc' },
17+
})
18+
.then((todos) => {
1819
res.json({
1920
todos: todos,
2021
page: page,
2122
});
22-
}));
23+
});
2324
}));
2425
},
2526

0 commit comments

Comments
 (0)