Would you like to clone this notebook?

When you clone a notebook you are able to make changes without affecting the original notebook.

Cancel

cities

node v6.17.1
version: master
endpointsharetweet
// create Cloudant connection var db = require("silverlining")(process.env.CLOUDANTURL + '/cities'); // query cities with population greater than 5 million var cities = await db.query({"population": { "$gt": 5000000 }});
// cities in Great Britain var cities = await db.query({"country": "GB"});
// get London, knowing its id var london = await db.get('2643743');
// pull two cities at once var cities = await db.get(['2643743','2642607']);
// get sum of populations by country var populationByCountry = await db.sum('population','country');
// turn into an array (for charting) for(var i in populationByCountry) { var p = populationByCountry[i]; populationByCountry[i] = [p,0]; // needs to be an array (for some reason) }; populationByCountry;
Loading…

no comments

    sign in to comment