News for hackers. Stuff that matters.

Mongodb - "grep" through a database

https://github.com/blowhacker/mongohelper

Helper functions for the mongodb shell

1. db.grep() -Search through all fields in all collections in a database for a value. By default it searches only indexed fields. To include non-indexed fields, specify the second parameter as true.

2. db.collection.fields() -list all keys in a collection -by default, it only checks 10100 documents to get an exhaustive list, if you document varies across the collection, do: db.collection.fields(true)

https://github.com/blowhacker/mongohelper

( 1 comment | 2 points | on HN )
Re:Mongodb - "grep" through a database by berito on Wednesday March 13, 2013 @09:31AM (#5368206)
I just ran collection.fields() on a collection of books. Surprised to find keys that I didn't even know existed.