The query document should only contain a single condition on the array field being projected. Multiple conditions may override each other internally and lead to undefined behavior. ref from mongo array field limitations因此,您尝试按照此方法仅查找exam或quizSo either you tried following this to find out only exam or quizdb.collectionName.find({"_id":22,"scores":{"$elemMatch":{"type":"exam"}}},{"scores.$.type":1}).pretty()仅显示exam分数数组.否则,您应该通过aggregation 这篇关于通过$ elemMatch在mongodb中提取两个子数组值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-19 13:00