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

mongodb

Solution

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?

Problem

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({'%':'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.

Original source

Related problems