收到消息" Hold"不是API调用中的函数

时间:2017-03-06 05:57:45

标签: node.js express

我有一个API(使用Node / Express)调用给我带来了一些麻烦。我有一个Model I引用,就像我所有的其他调用一样,但出于某种原因,当我尝试创建一个" Hold"您将在下面的代码中看到的模型,我收到一条错误,指出{"错误":" Hold不是构造函数"}。

有人能看出为什么我会收到这条消息吗?

这是我的终点:

var express = require('express');
var router = express.Router();
var Card = require('../models/cards');
var Hold = require('../models/hold');
var Profile = require('../models/profile');
var vCard = require('vcards-js');
var GuidGen = require('./helpers/generate_guid');
var sendmail = require('./helpers/post_office');
var constants = require('./helpers/constants');

router.route('/invite')

.post(function( req, res ){

  var hold = new Hold();
  var msgs = '';


// INSERT NEW REQUEST INTO HOLD COLLECTION
  hold.owner_id = req.body.ownerId; 

  //hold.date_invited = Date.now();
  hold.invited_email = req.body.invited_email;
  hold.invited_first_name = req.body.invited_first_name;
  hold.invited_last_name = req.body.invited.last_name;


  hold.status = req.body.status

  hold.first_name = req.body.first_name;
  hold.last_name = req.body.last_name;
  hold.initial = req.body.initial;
  hold.birthday = req.body.birthday;
  hold.highschool = req.body.highschool;
  hold.college = req.body.college;
  hold.facebook = req.body.facebook;
  hold.linkedin = req.body.linkedin;
  hold.user_image = req.body.user_image;

  hold.phones = req.body.phones;
  hold.emails = req.body.emails;
  hold.addresses = req.body.addresses;
  hold.businesses = req.body.businesses;

  hold.save(function(err){
    if(err)
      res.send('First Error Point' + err);  
    //res.json(hold);
    msgs = 'INSERT NEW REQUEST INTO HOLD COLLECTION - success; ';
  });

1 个答案:

答案 0 :(得分:0)

jfriend00是对的。问题是我没有正确导出构造函数。