mongolass 中报 ($.content: "say Hi ~") ✖ (type: String)

第二次报这个错了, 一直以为MongoDB的模型用的type 是 String, 一直报错, 找不到原因.

// 留言模型1
  exports.Comment = mongolass.model('Comment',{
	  author: {type: Mongolass.Types.ObjectId, require:true},
	  content: { type: 'String', required: true },
	  postId: {type: Mongolass.Types.ObjectId, require: true}
  })
  exports.Comment.index({ postId: 1, _id:1 }).exec();	// 通过文章ID获取该文章下所有留言,按留言创建时间升序

  exports.Comment = mongolass.model('Comment', {
	author: { type: Mongolass.Types.ObjectId, required: true },
	content: { type: 'string', required: true },
	postId: { type: Mongolass.Types.ObjectId, required: true }
  })
  exports.Comment.index({ postId: 1, _id: 1 }).exec()

  

由于把string 写成了大写的String导致找不到错误的原因

 

posted @ 2018-09-29 18:34  仲柯  阅读(244)  评论(0编辑  收藏  举报