Skip to content

Very simple implementation of some of mongodb aggregation framework functions for Meteor

Notifications You must be signed in to change notification settings

zvictor/meteor-mongo-server

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mongodb-server-aggregation

Very simple implementation of some of mongodb aggregation framework functions for Meteor.

Mongodb-server-aggregation is a fork of mongodb-aggregation that do not expose the aggregation framework to the client, being available only on server side.

It extends Collection with 3 methods so far, mapReduce, distinct and aggregate, so that you can do:

    col = new Meteor.Collection "name"

    if Meteor.isServer
        # mapReduce
        map = function() {emit(this.Region, this.Amount);}
        reduce = function(reg, am) { return Array.sum(am);};

        col.mapReduce map, reduce, {out: "out_collection_name", verbose: true}, (err,res)->
            console.dir res.stats # statistics object for running mapReduce
        
        # distinct
        result = col.distinct "Field Name"
        console.dir result

        #aggregate
        result = col.aggregate pipeline
        console.dir result

To install it, run:

$ mrt add mongodb-server-aggregation

You can also perform Mongo's inline mapReduce query by not specifying 'out' option at all or by setting it to out: {inline: 1}. The result must fit within the maximum size of a BSON document (which is 16 megabytes by default).

This package is MIT Licensed. Do whatever you like with it but any responsibility for doing so is your own.

About

Very simple implementation of some of mongodb aggregation framework functions for Meteor

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • CoffeeScript 81.7%
  • JavaScript 18.3%