我想找到具有特殊价值且与其他文档具有相同引用ID的文档 例如
{departur: mxp, arrival: las, _itinerary:111}
{departur: las, arrival: ist, _itinerary:111}
{departur: ist, arrival: bgw, _itinerary:222}
{departur: bgw, arrival: dnz, _itinerary:222}
{departur: mxp, arrival: ist, _itinerary:333}
{departur: ist, arrival: tgd, _itinerary:333}
{departur: mxp, arrival: lmy, _itinerary:444}
{departur: bgw, arrival: qrz, _itinerary:444}
我想要departur:mxp和arrival:ist,但使用相同的_itinerary ID 例如,我需要上面的值
{departur: mxp, arrival: las, _itinerary:111}
{departur: las, arrival: ist, _itinerary:111}
{departur: mxp, arrival: ist, _itinerary:333}
如何在猫鼬查询或多个查询中找到它
const flightItinerarySchema = new Schema(
{
_flightSegments: [{ type: Schema.Types.ObjectId, ref: 'FlightSegment'}]
}
);
const flightSegmentSchema = new Schema(
{
_flightItinerary: {
type: Schema.Types.ObjectId,
ref: 'FlightItinerary'
},
departure: String,
arrival: String
}
);