zoukankan      html  css  js  c++  java
  • 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导致找不到错误的原因

  • 相关阅读:
    Collection LinkedList
    java 浅拷贝和深拷贝
    Collection ArrayList
    Java 集合
    Activity、Fragment、Service、View生命周期
    Android 事件分发机制
    retrofit2.0
    Android 知识图谱
    设计模式-代理模式
    多线程-lock
  • 原文地址:https://www.cnblogs.com/zhongke/p/9725377.html
Copyright © 2011-2022 走看看