Revert "Changed table query from mapreduce to aggregation pipeline"

This reverts commit d582e96ace9f18e7f0fff0ee8cd6fc4eb8b1296c.