Fetch D3.js Array From A Url
This is the kind of data that I have { '_id' : ObjectId('kdahfa'), 'minTime' : ISODate('2016-04-02T00:00:00.000+0000'), 'maxTime' : ISODate('2016-04-02T00:11:00.000+0000'), 'Time
Solution 1:
a = dbcoll.find_one({},{'_id':False})
In this line, you are only querying for one entry in your database, that is why the result returned is a single object instead of an array (probably you also need to change the first parameter {}
to []
or something to denote array but I am not familiar with dbcoll
.
You need to change find_one
into find
or something, and you will get an array.
Then the post-processing, you needs to iterate through the array of a
:
a = a.map(function(b){
b['minTime'] = str(b['minTime'])
b['maxTime'] = str(b['maxTime'])
return b;
}
In MongoDB there is a method find
: https://docs.mongodb.com/manual/reference/method/db.collection.find/
Post a Comment for "Fetch D3.js Array From A Url"