如何在mongoosejs中查找全部? [英] How to findAll in mongoosejs?

查看:97
本文介绍了如何在mongoosejs中查找全部?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码是这样的:

SiteModel.find(
    {},
    function(docs) {
        next(null, { data: docs });
    }
);

但是它从不返回任何内容...但是,如果我在{}中指定内容,那么会有一条记录.那么,如何查找全部?

but it never returns anything... but if I specify something in the {} then there is one record. so, how to findall?

推荐答案

尝试以下代码进行调试:

Try this code to debug:

SiteModel.find({}, function(err, docs) {
    if (!err) { 
        console.log(docs);
        process.exit();
    }
    else {
        throw err;
    }
});

这篇关于如何在mongoosejs中查找全部?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆