A python implementation of mongodb queries