0
我想從mongo中找到一個文檔,但是findOne()將帶有一個未定義的_id字段的文檔。 爲什麼?貓鼬不檢索_id
var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/school');
var Schema = mongoose.Schema;
var scoreSchema = new Schema({
type: String,
score: Number
});
var studentSchema = new Schema({
name: String,
scores: [scoreSchema]
});
var mod = mongoose.model('Student', studentSchema);
mod.findOne(function(err, stud) {
console.log('id:' + stud._id);
});