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

ansarizafar/meteor-mongo-server

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 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

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