foo.find(…).execFind不是函数 – mongoose模式模型

我已经定义了一个自定义的types,我试图从被引用的集合中包含的mongo返回所有的条目:

Participant.js

var mongoose = require('mongoose'); var Schema = mongoose.Schema; var participantSchema= new Schema({ email: String, }); module.exports = mongoose.model('Participant', participantSchema, 'participants') 

api.js

 var express = require('express'); var router = express.Router(); var mongoose = require('mongoose'); var Participant = require('../models/Participant'); router.get('/all', function(req, res) { var participant = mongoose.model('Participant'); //var participant = new Participant(); console.log(participant); participant.find().execFind(function (arr,data) { res.send(data); }); }); module.exports = router; 

但由于有点可疑,我的模型不扩展(我假设默认的原型)

  participant.find(...).execFind is not a function TypeError: participant.find(...).execFind is not a function at /Users/bogdan/private/appName/routes/api.js:13:24 

任何帮助,高度赞赏…谢谢

在Mongoose的3.x版本之一中, execFindexec取代。

所以你现在必须调用exec而不是execFind