node v6.14.1
version: master
// 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;

no comments

    sign in to comment