我有两个如下文件。
const ClaimDetailsSchema = mongoose.Schema({
_id: mongoose.Schema.Types.ObjectId,
benefitArea: String,
gfo: String,
productForm: String,
type: String,
status: String,
claimTitle: String,
claimId: String,
claimName: String,
exception: String,
createdBy: String,
createdByNtId: String,
lastModifiedBy: String,
claimType: {
historyId: String,
commentId: String,
exportId: String,
version: String,
reason: String
},
Substantiations: [{ type: mongoose.Schema.Types.ObjectId, ref: 'Substantiations' }],
Formulaes: [{ type: mongoose.Schema.Types.ObjectId, ref: 'Formulaes' }],
regions: [String],
favorites: [String],
claimCreatedDate: { type: Date, default: Date.now },
lastModifiedDate: { type: Date }
});
module.exports = mongoose.model('ClaimDetails', ClaimDetailsSchema);
const mongoose = require('mongoose'), Schema = mongoose.Schema;
const SubstantiationSchema = mongoose.Schema({
_id: mongoose.Schema.Types.ObjectId,
substantiation: String
});
module.exports = mongoose.model('Substantiations', SubstantiationSchema);
我需要基于where子句中的证明文本来获取ClaimDetails。
我尝试过以下方法,但是没有运气。
exports.testCase = (req, res) => {
Claimdetails.find().populate({ path: 'Substantiations', match: { substantiation: 'rel' } }).exec(function (err, claims) {
res.send({ data: claims });
});
};