Aggregation Framework pipelines. It is based on the concept of Fluent APIs and automatically handles a lot of the necessary pipeline stages that are just a means to an end (like
$projecting nested fields to the top level, etc).
And then open http://localhost:8080/__zuul in a browser.
Of course the preferred way to use -querybuilder is npm+browserify, but sometimes being able to just drop a script tag into a codepen is nedded.
- Create a GitHub Access Token
- Export your access token as
npm run-script dist
- Setup travis for saucelabs. see zuul docs
- Write lots more tests
The query builder turns that:
Full example (see also index.html):
Constructor to create a new QueryBuilder. Takes an
options hash. The options are:
|scope||hostname/port of mongoscope, passed on to mongoscope-client|
|seed||hostname/port of MongoDB database, passed on to mongoscope-client|
|namespace||namespace to query against, in
|samples||number of samples to create schema from|
var builder =scope: ""seed: "mongodb://localhost:27017"namespace: "foo.bar"samples: 500;
Specify a filter to be matched when querying for documents. This turns into the
$match aggregation stage. The
value parameter is interpreted differently depending on the type of
|date||Same as number. Both
.match() call on the same field is repeated, the value of that field is overwritten. Specifying a value of
undefined removes the filter on this field.
.match() filters on different fields are specified, the resulting documents have to match all filters.
builder// match users with these last names// match users with age between 18 and 36 (inclusive)// match users created between these dates
Group documents by their value of
field and projects this value to a new field named
name. MongoDB combines grouping and aggregating (or "rolling up" values) into a single
$group stage. Therefore, a call to
.group() is usually followed by one or more calls to
This example groups all documents by their
user.address.zip_code field, and renames the field to
zip in the process. For each group, the total number of documents is calculated as
count and the average age of the users is calculated as
average_age. The result could look like this:
You can also group on multiple fields at once. The syntax is the same as above, but instead of a single
field value, specify an array of values. The resulting groups cover all combinations of the compound group key.
Due to a limitation of the aggregation framework around dot-notation keys (they can only appear at the top level), all dots are replaced with underscores in the resulting compound group key (e.g.
user_address_zip_code instead of