![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
aggregate-stream
Advanced tools
fluent aggregate query builder with promise and streaming support
A wrapper around MongoDB's .aggregate()
function:
This is based on maggregate which is not up to date with MongoDB 2.6+ and friends.
var aggregate = require('aggregate-stream');
// return all the results at once
aggregate(collection)
.match({
'identity': 'person'
})
.group({
_id: '$_id',
count: {
$sum: 1
}
})
.toArray(function (err, docs) {
})
// as a promise
aggregate(collection)
// pipeline...
.then(function (docs) {
}, function (err) {
})
// as a stream
http.createServer(function (req, res) {
res.setHeader('content-type', 'application/json')
aggregate(collection)
// pipeline...
.pipe(JSONStream.stringify())
.pipe(res)
})
Return a new aggregation instance with options. See options: http://mongodb.github.io/node-mongodb-native/api-generated/collection.html#aggregate
Set an option after initialization.
aggregate(collection).set('readPreference', 'secondaryPreferred')
Manipulate each document before returning them.
aggregate(collection)
.transform(function (doc) {
doc.transformed = true;
return doc
})
Each operator is its own method. See: http://docs.mongodb.org/manual/meta/aggregation-quick-reference/#aggregation-operator-quick-reference
aggregate(collection)
.match({
type: 'human'
})
Return all the results as a single array. If no callback is supplied, a promise is returned.
aggregate(collection)
// pipeline...
.toArray(function (err, docs) {
})
Return the "explain" on the query. If no callback is supplied, a promise is returned.
aggregate(collection)
// pipeline...
.then(console.log)
Destroy the stream. Use this to prevent any leaks.
http.createServer(function (req, res) {
var stream = aggregate(collection)
req.socket.once('close', function () {
// always make sure this cursor is closed when the request is finished
stream.destroy()
})
})
A wrapper around .toArray()
that can be implicitly called by a control flow engine.
co(function* () {
var docs = yield aggregate(collection).match().group() // ...
})
This makes each instance a "promise",
but you shouldn't be using .then()
directly - use .toArray()
instead.
FAQs
fluent aggregate query builder with promise and streaming support
The npm package aggregate-stream receives a total of 1 weekly downloads. As such, aggregate-stream popularity was classified as not popular.
We found that aggregate-stream demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.