0
私は2つのモデルを持っており、顧客モデルの各IDの状態をステータスモデルから探したいのですが、ここで集計を使用していますが、誰でも助けてください.............................................mongoose集約が空の配列を返す
///顧客モデル
///テーブル名は、データベース内のcrmcustomersある
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var schemaOptions = {
timestamps: true,
toJSON: {
virtuals: true
}
};
var CrmCustomerSchema = new Schema({
name: String,
shop_name: String,
address: String,
phone: { type: String, unique: true},
comment: String,
email: String,
website : String,
interest: String,
reference : String,
}, schemaOptions);
var CrmCustomer = mongoose.model('CrmCustomer', CrmCustomerSchema);
module.exports = CrmCustomer;
///ステータスモデル
///テーブル名210は、クエリ
CrmCustomer.aggregate([
{
"$lookup": {
"from": "crmcustomerstatus",
"localField": "_id",
"foreignField": "crm_id",
"as": "result"
}
},
]).exec(function(err, results){
console.log(results);
})
///は空の結果を取得するための
[ { _id: 5a1cf755b5268904a476c7d2,
updatedAt: 2017-11-28T05:42:45.239Z,
createdAt: 2017-11-28T05:42:45.239Z,
name: 'istiaque ahmad',
shop_name: 'les mecaron',
address: 'mirpur',
phone: '01764199657',
email: '[email protected]',
website: 'xccxxxxx',
comment: 'dsfsdf',
interest: 'dsfsdf',
reference: 'dsfsdfsdf',
__v: 0,
result: [] } ]