在我的mongodb数据库上找不到任何东西

时间:2016-10-08 14:43:50

标签: javascript node.js mongodb mongoose

我使用猫鼬做了一个奇怪的行为。我得到了空数组,但我的文档有一些文档。这是我的Account.js:

var mongoose = require('mongoose');
var Schema = mongoose.Schema;

var accountSchema = mongoose.Schema({
    username: String,
    password: String,
    cover: String,
    createAt: {type: Date, default: Date.now},
    subscriber_email: String
});

var Account = module.exports = mongoose.model('account', accountSchema);

module.exports = Account;

这是我的控制器,文件名是home.js

var User = require('../models/User');
var Account = require('../models/Account');

exports.getNumberOfAccounts = function(req, res) {
    Account.find({}, function(err,response){
        console.log(response)
    });
}

我怎么能在server.js

var app = express();
var homeController = require('./controllers/home');
app.post('/getNumberOfAccounts', homeController.getNumberOfAccounts);

哪个部分我做错了?我总是得到空阵。

0 个答案:

没有答案