tags:

views:

74

answers:

1

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.

+2  A: 

It is possible to query the property names (key names) with map reduce. See here: http://stackoverflow.com/questions/2298870/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?

Theo
No concrete use cases other than discussions with a DB guy working on a cell database concept. His common example was "find me everything that's red". Most likely used for manipulating data at a later point in time, or useful perhaps for data updates or clean up. One example might be find everything that looks like a zip code, or find all stored instances of a particular email address throughout the system.
tgm