Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

ts-aggregate

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ts-aggregate

A simple wrapper for aggregating time series data for mongodb.

latest
Source
npmnpm
Version
0.1.2
Version published
Maintainers
1
Created
Source

ts-aggregate

A simple wrapper for aggregating time series data for mongodb.

Installation

npm install ts-aggregate

Usage

var aggregate = require('ts-aggregate');
var config = {
  mongoUrl: 'mongodb://localhost:27017/my_app',
  collectionName: 'users',
  // db: connection_string
};
var options = {
  dateField: 'created_on',            // date field which you want to show as time series
  criteria: {                         // criteria
    created_on: {
      $gte: new Date('2015-06-01'),
      $lte: new Date('2015-07-01')
    }
  }
};

aggregate(config, options, function (err, docs) {
  // console.log(docs);
  // =>
  // [ { count: 7, date: '2015-6-9' },
  //   { count: 9, date: '2015-6-8' },
  //   { count: 11, date: '2015-6-7' },
  //   { count: 4, date: '2015-6-6' },
  //   { count: 4, date: '2015-6-5' },
  //   { count: 3, date: '2015-6-4' } ]
});

License

MIT

FAQs

Package last updated on 08 Jul 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts