最佳答案
我数据库里的记录是
{"_id":"1","fn":"sagar","ln":"Varpe"}
{"_id":"1","fn":"sag","score":"10"}
{"_id":"1","ln":"ln1","score":"10"}
{"_id":"1","ln":"ln2"}
我需要设计一个 MongoDB 查询来查找具有给定密钥的所有记录。
例如,如果我将 ln
作为参数传递给查询,那么它应该返回其中 ln
为键的所有记录。结果会是
{"_id":"1","fn":"sagar","ln":"Varpe"}
{"_id":"1","ln":"ln1","score":"10"}
{"_id":"1","ln":"ln2"}