我有一个管道及其结果,我想通过一个表达的方法返回它,无论是否获取,我都知道通过套接字发送它是否更可取
这是我的文件pipeline.js:
function getModel(model) {
model.aggregate([{
$group: {
_id: null,"price": {
$sum: "$price",}
}
}]).exec((e,d) => {
return JSON.stringify(d)
})
}
module.exports = getModel;
在model.js文件中,我将调用pipeline.js文件,并因此调用函数
model.js:
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const getModel = require('./pipeline');
const mySchema = new Schema({
user: {
type: Schema.ObjectId,ref: 'User'
},namepet: String,type_of_service: String,characteristic_of_pet: String,price: Number
});
const model = mongoose.model('Cites',mySchema);
here is the function-> getModel(model);
module.exports = model;
它对我有用,因为我想要的问题是我必须通过get方法发送它的结果,而我不知道该怎么做
如何通过get方法发送指示图像红色箭头的结果?