from mongoose to promised-mongo

This commit is contained in:
tmshv committed 2015-02-28 05:35:49 +03:00
1 parent 627a18c5fa
commit 737bebec15
6 files changed
+41 -38

No files matched your search

+8 -8
View File
@@ -3,20 +3,20 @@
*/
var Router = require("express").Router;
var Post = require("../schema/post");
var db = require("../core/db");
module.exports = function (app) {
var router;
router = new Router();
router.route("/api/feed")
.get(function (req, res) {
Post.find({}).exec(function (error, list) {
if (error) return res.error(error);
res.json(list.map(function (post) {
return post.toObject();
}));
});
db.c("posts").find().toArray()
.catch(function(e){
res.error(e);
})
.then(function (docs) {
res.json(docs);
});
});
app.use(router);
};