君临天下之福邻忠帼3年前
实例化方法: userSchema.methods.print=function() { console.log(this.allName+"::"); console.log(this.blog); } 调用实例化方法,好像只能用定义过的实例调用,用查找到的结果调用不行
0
君临天下之福邻忠帼3年前
实例化方法: userSchema.methods.print=function() { console.log(this.allName+"::"); console.log(this.blog); } 调用实例化方法,好像只能用定义过的实例调用,用查找到的结果调用不行
0
君临天下之福邻忠帼3年前
User.findByBlog('11.comhttp://',function(err,doc) { if (err) { return consloe.log(err); } return console.log(doc); })
0
君临天下之福邻忠帼3年前
使用静态方法查询: userSchema.statics.findByBlog=function(blog,cb) { this.findOne({blog:blog},function(err,doc) { cb(err,doc);//回调函数 }) }
0