我有两个猫鼬模特。 页面和缩略图
var Page = new Schema({
title: { type: String, default: '', trim: true },
url: { type: String, default: '', trim: true },
thumbnails: {type: Schema.ObjectId, ref: 'Thumbnails'},
});
Page.post('save', function(doc) {
if(doc.thumbnails) return;
Thumbnail.generate(doc.url, function(err, thumb){
doc.thumbnails = thumb;
doc.save()
});
});
var Thumbnail = new Schema({
domain: {type: String, trim: true},
url: {
small: { type: String, trim: true },
original: {type: String, trim: true }
}
});
Thumbnail.statics.generate = function(doc, cb) {
// generate site preview , save the thumbnail and call cb
}
我正在使用mongoose post中间件来生成缩略图 如何在Post中间件中测试 Thumbnail.generate 是否被调用?
由于