mongodb 中间件不进入
const mongoose = require('mongoose');
mongoose.connect('mongodb://192.168.99.100:32768/daai');
let ChildSchema = new mongoose.Schema({
name: String,
gender: Number, /* 0: female, 1: male */
head: {type: mongoose.Schema.Types.ObjectId, ref:'Upload'},
psychicFactor: [{type: mongoose.Schema.Types.ObjectId, ref:'PsychicFactor'}],
birthDate: {
year: Number,
month: Number,
day: Number
},
user: {type: mongoose.Schema.Types.ObjectId, ref: 'User'},
},{collection: 'Child'});
var Child = mongoose.model('Child', ChildSchema);
ChildSchema.pre('find', function() {
console.log("进入");
next();
});
Child.find({_id:"571599ad0c81f39bff0e9ed1"}).exec(function(err,doc){
console.log(doc);
});
只打印了doc,不打印进入
管理员温馨提示:发帖前请先简单学一下Markdown语法