【发布时间】:2016-04-22 18:29:04
【问题描述】:
我已经定义了一个自定义类型,我正在尝试从包含在引用集合中的 mongo 返回所有条目:
参与者.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
非常感谢任何帮助... 谢谢
【问题讨论】:
-
尝试调用
exec而不是execFind。 -
谢谢,添加评论,也许你能解释一下有什么区别:p
-
execFind在 3.x 版本之一中被删除,不确定何时。反正已经被exec取代了。 -
add answere s oi 可以接受 :)
标签: node.js mongodb mongoose schema