JavaScript MongoDB查询未定义

时间:2015-10-19 23:05:15

标签: javascript mongodb undefined

我的server.js文件中有以下查询:

Breed.find({$and: [
    {$or: [ { size: 's' }, { size: 'm' } ]},
    {$or: [ { exercise: 'two' }, { exercise: 'three' } ]},
    {$or: [ { training: 'two' }, { training: 'three' } ]},
    {$or: [ { grooming: 'two' }, { grooming: 'three' } ]},
    {$or: [ { catfriendly: 'two' }, { catfriendly: 'three' } ]},
    {$or: [ { protective: 'two' }, { protective: 'three' } ]},
    {$or: [ { affection: 'three' }, { affection: 'four' } ]}
    ]}, function (err, matches) {
    console.log('these are the matches: ' + matches);
    res.json(matches);
});

它以未定义的形式返回。但是我在Mongo终端运行了这个查询:

db.breeds.find({$and: [ {$or: [ { size: 's' }, { size: 'm' } ]},{$or: [ { exercise: 'two' }, { exercise: 'three' } ]}, {$or: [ { training: 'two' }, { training: 'three' } ]},{$or: [ { grooming: 'two' }, { grooming: 'three' } ]},{$or: [ { catfriendly: 'two' }, { catfriendly: 'three' } ]},{$or: [ { protective: 'two' }, { protective: 'three' } ]},{$or: [ { affection: 'three' }, { affection: 'four' } ]}]});

它会返回与查询匹配的4个品种。我的server.js文件中缺少什么使它返回undefined?我试过控制台记录类型匹配,它也说未定义。

1 个答案:

答案 0 :(得分:1)

您是否需要在server.js中使用您的Breed模型?

相关问题