开发者

Can you query MongoDB for any properties with a given value?

开发者 https://www.devze.com 2022-12-22 06:27 出处:网络
I\'m beginning to play around with MongoDB and I\'m wondering if it\'s possible to query the datastore for any property with a particular value.

I'm beginning to play around with MongoDB and I'm wondering if it's possible to query the datastore for any property with a particular value.

So instead of:

db.foo.find({'color':'red'})

I'm looking to see if you can do something like:

db.foo.find开发者_Go百科({'%':'red'})

Is that possible? Is there a syntax for wildcarding the property slot? I tried using a regular expression but that gave me an error.


It is possible to query the property names (key names) with map reduce. See here: MongoDB Get names of all keys in collection

Maybe it is possible to write a map reduce function that queries on the combination of a property name and its value with JavaScript?

But why do you need this?

0

精彩评论

暂无评论...
验证码 换一张
取 消