Initial support for MongoDB.

Support simple queries using the a JSON format:
{
	"collection" : THE NAME OF THE COLLECTION TO QUERY,
	"query" : {
		A DICTIONARY FOR QUERYING FIELDS (similar to what you would find in PyMongo
	},
	"fields" : {
		LIST OF FIELDS TO RETURN IN THE SPECIFIED ORDER
	},
	"sort" : {
		LIST OF FIELDS TO SORT BY (1 - Ascending, -1 - descending)
	}
}

For example:
{
	"collection" : "mycoolcollection",
	"query" : {
		"fieldA" : { "$gte" : 5 },
		"created" : { "$lt" : "ISODate(\"2014-09-01 23:43\")" }
	},
	"fields" : {
		"fieldA" : 1,
		"created" : 2
	},
	"sort" : {
		"created" : -1
	}
}
It will throw an exception. Just not a nice one.

I will add a check and error just for that.
On Oct 2, 2014 7:49 AM, "Arik Fraimovich" <notifications@github.com> wrote:

> In redash/data/query_runner_mongodb.py:
>
> > +                return c
> > +
> > +        return None
> > +
> > +    def _convert_date(q, field_name):
> > +        m = date_regex.findall(q[field_name])
> > +        if len(m) > 0:
> > +            if q[field_name].find(":") == -1:
> > +                q[field_name] = datetime.datetime.fromtimestamp(time.mktime(time.strptime(m[0], "%Y-%m-%d")))
> > +            else:
> > +                q[field_name] = datetime.datetime.fromtimestamp(time.mktime(time.strptime(m[0], "%Y-%m-%d %H:%M")))
> > +
> > +    def query_runner(query):
> > +        db_name = connection_string.split("/")[-1]
> > +
> > +        db = pymongo.MongoClient(connection_string)[db_name]
>
> Maybe worth wrapping this with error handling, in case the db name isn't
> found?
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/EverythingMe/redash/pull/298/files#r18322227>.
>