3

我正在寻找一种方法来修改猫鼬的查询结果。

下面是带有后挂钩的自包含模型

'use strict';

// load the things we need
var mongoose = require('mongoose');
var invoice_db = mongoose.createConnection(config.mongo.url + '/invoiceDB'); //connect to buyer DB
var path = require('path');


// define the schema for our invoice details model
var invoicedetailSchema = new Schema({
    //SCHEMA INFO
});

invoicedetailSchema.post('find', function(results){

console.log('POST FIRED')

    results = results.filter(function(doc){
     return doc.tags.length;
   })
})

var InvoiceModel = invoice_db.model('InvoiceDetail', invoicedetailSchema);


// create the model for seller and expose it to our app
promise.promisifyAll(InvoiceModel);
promise.promisifyAll(InvoiceModel.prototype);
module.exports = InvoiceModel;

查找查询工作正常,帖子正在触发,但结果未按帖子挂钩过滤。

在返回结果之前如何编辑结果。

4

0 回答 0