A JavaScript data aggregation pipeline based on the MongoDB database's aggregation framework. https://riveragroup.github.io/mungedb-aggregate/
|
|
12 years ago | |
|---|---|---|
| lib | 12 years ago | |
| npm_scripts | 12 years ago | |
| test | 12 years ago | |
| .gitignore | 12 years ago | |
| .jscheckstyleignore | 12 years ago | |
| .jshintrc | 12 years ago | |
| README.md | 12 years ago | |
| mungedb-aggregate.js | 12 years ago | |
| package.json | 12 years ago |
A JavaScript data munging pipeline based on the MongoDB aggregation framework.
In general, this code is a port from the MongoDB C++ code (v2.4.0) to JavaScript.
TODO: document the major exports and a little about each here
Here is a list of the major items where we have deviated from the MongoDB code and a little bit about why:
.cpp file in the MongoDB code but to keep things clean and separate they have been broken out into files named the same and only rarely is there more than one class within a single fileBSON vs JSON
BSON-specific code has become equivalent JSON-specific code since that's what we're working with (no need for needless conversions)addToBson... and other BSONObjBuilder-related methods that take in an instance to be modified but it's owned by the caller; in munge we build a new Object and return it because it's simpler and that's how they're generally used anyhowDocument class
Document now provides static helpers rather than instance helpers to avoid unecessary boxing/unboxing since that seems to make more sense here (we treat any Object like a Document)Value class
Value now provides static helpers rather than instance helpers to avoid unecessary boxing/unboxing since that seems to make more sense here (we treat any Object like a `Value)Value#get{TYPE} methods have been renamed to Value.verify{TYPE} since that seemed to make more sense given what they're really doing for us as staticsValue.coerceToDate static returns a JavaScript Date object rather than milliseconds since that seems to make more sense where possibleExpression classes
Expression base classObjectCtx class no longer uses contants and bitmask flags, instead it takes an Object with similarly named keys that are expected to be Booleans; e.g., {isDocumentOk:true} rather than DOCUMENT_OKExpression{FOO} classes have all been renamed to {FOO}Expression to satisfy my naming OCD.{FOO}Expression classes do not provide create statics since calling new is easy enoughCompareExpression class doesn't provide any of it's additional create{FOO} helpers so instead I'm binding the appropriate args to the constructormunge-only expressions that have not been ported back to MongoDB yetIndexOfExpression or $indexOf - A new Expression that returns the index of an item in an Array or StringDocumentSource classes
reset method for all document sources so that we can reuse them against different streams of dataHere is a list of global items that I know about that may need to be done in the future:
constructor? or at least a const prototype property or somethingBSON types to do everything properly; affects handling of ObjectId, ISODate, and Timestampassert.equal() calls into assert.strictEqual() callsexports = module.exports = with module.exports = onlythrow and make them actually use UserException vs SystemException (or whatever they're called)/** documentation **/ to ensure that they are YUIDoc-fiendly and exist on multiple linesseal, freeze, etc.) where appropriatevirtuals (i.e., /virtual .* = 0;$/) are implemented as a proto with a throw new Error("NOT IMPLEMENTED BY INHERITOR") or similaruassert might be munge.UserException) so they can be caught properlysift package to fake the MatchDocumentSource class but need to actually port the real code