Skip to content

Show HN: grep through an entire mongo database

1 pointvaindiscuss
On HN

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)

To use, copy and paste the contents of mongohelper.js into your mongo shell. or: load("/path/to/mongohelper.js");

available here: https://github.com/blowhacker/mongohelper/blob/master/mongohelper.js

Comments

No comments yet.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.