创建了person collection,通过mongoose的save 保存后自存存储为people, 以至于查不到数据
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
//var db = mongoose.connect('mongodb://localhost/doracms');
var shortid = require('shortid');
var person= new Schema({
_id: {
type: String,
unique: true,
'default': shortid.generate
},
name: String,
age: Number,
email : String,
qq : String,
phoneNum : String,
comments : { type: String, default: "这个人很懒,什么都没有留下..." },
position : String // 职位
});
var Person= mongoose.model("person",person);
module.exports = Person;
查询时一直取不到数据: //主要原因是mongoose把person collection 变成了perople, mongoose调试时如果取不到数据,就先插入一条数据试试,看多了什么collection
Person.find({}, function (err,result) {
if(err){
}else{
console.log("lala"+" success!"+result)
return res.send(result);
}
})