title: How to simulating the aggregate functions avg, sum, max, min, and count on PouchDB?
body: <p>Does anyone know how to create aggregate functions, for example avg, sum, max and min on PouchDB database. I created a simple application to test the PouchDB. I'm still not figured out how to run these commands. Thanks in advance.</p>
  
  <p>For example. How do you get the highest, lowest or average for the "number" field?</p>
  
  <blockquote>
    <p>My main Ionic 2 component</p>
  </blockquote>
  
  <pre><code>import {Component} from '@angular/core';
  import {Platform, ionicBootstrap} from 'ionic-angular';
  import {StatusBar} from 'ionic-native';
  import {HomePage} from './pages/home/home';
  declare var require: any;
  var pouch = require('pouchdb');
  var pouchFind = require('pouchdb-find');
  @Component({
      template: '&lt;ion-nav [root]="rootPage"&gt;&lt;/ion-nav&gt;'
  })
  export class MyApp {
      rootPage: any = HomePage;
      db: any;
      value: any;
      constructor(platform: Platform) {
          platform.ready().then(() =&gt; {
              StatusBar.styleDefault();
          });
          pouch.plugin(pouchFind);
          this.db = new pouch('friendsdb');
          let docs = [
              {
                  '_id': '1',
                  'number': 10,
                  'values': '1, 2, 3',
                  'loto': 'fooloto'
              },
              {
                  '_id': '2',
                  'number': 12,
                  'values': '4, 7, 9',
                  'loto': 'barloto'
              },
              {
                  '_id': '3',
                  'number': 13,
                  'values': '9, 4, 5',
                  'loto': 'fooloto'
              }
          ];
          this.db.bulkDocs(docs).then(function (result) {
              console.log(result);
          }).catch(function (err) {
              console.log(err);
          });
      }
  }
  ionicBootstrap(MyApp);
  </code></pre>