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:
Document
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
)Expression
class
ObjectCtx
class no longer uses contants and a bit flags but instead uses similarly named boolean; e.g., isDocumentOk
rather than DOCUMENT_OK
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{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 enough
CompareExpression
class doesn't provide any of it's additional create{FOO}
helpers so instead I'm binding the appropriate args to the ctorBSON
-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 anyhowHere is a list of global items that I know about that may need to be done in the future:
getOpName
should be static!BSON
types to do everything properly; affects handling of ObjectId
, ISODate
, and Timestamp
assert.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 appropriatevirtual
s (i.e., /virtual .* = 0;$/) are implemented as a proto with a throw new Error("NOT IMPLEMENTED BY INHERITOR") or similar