mongodb通配符匹配特定键的所有值 [英] mongodb wildcard match all values for specific key

查看:800
本文介绍了mongodb通配符匹配特定键的所有值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图弄清楚如何匹配一个键并返回该键的所有值.是否可以将值设置为通配符?我想使用值上的通配符返回该特定键的所有内容.

I am trying to figure out how to match a key and return all the values for that key. Is it possible to give the value as a wildcard? I want to return everything for that specific key using wildcard on the value.

db.collection.find({"key" :"*"})

我还希望它也将返回具有与通配符值匹配的键的整个集合.

Also I was hoping this would return the entire collection as well that had the key with the wildcard value match as well.

推荐答案

您可能正在寻找这样的东西:

You may be looking for something like this:

db.collection.find({"key": {$exists: true}})

这将返回存在键"key"的集合中的所有文档.返回整个文档.

This will return all documents in the collection where the key "key" is present. The entire document is returned.

这篇关于mongodb通配符匹配特定键的所有值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆