Comparing version 0.6.4 to 0.7.0
var mongodb = require('mongodb'); | ||
var memolite = require('memolite'); | ||
var Readable = require('stream').Readable || require('readable-stream'); | ||
@@ -27,5 +28,8 @@ var DRIVER_COLLECTION_PROTO = mongodb.Collection.prototype; | ||
var Cursor = function(oncursor) { | ||
Readable.call(this, {objectMode:true}); | ||
this._get = oncursor; | ||
}; | ||
Cursor.prototype.__proto__ = Readable.prototype; | ||
Cursor.prototype.toArray = function() { | ||
@@ -72,2 +76,6 @@ this._apply(DRIVER_CURSOR_PROTO.toArray, arguments); | ||
Cursor.prototype._read = function(size, callback) { // 0.10 stream support | ||
this.next(callback); | ||
}; | ||
Cursor.prototype._config = function(fn, args) { | ||
@@ -74,0 +82,0 @@ if (typeof args[args.length-1] !== 'function') return this._apply(fn, args); |
{ | ||
"name":"mongojs", | ||
"description":"a simple mongo module that implements the mongo api", | ||
"keywords": ["mongo", "db", "mongodb"], | ||
"version":"0.6.4", | ||
"repository": "git://github.com/gett/mongojs.git", | ||
"author": "Ge.tt <hello@ge.tt>", | ||
"contributors": [ | ||
"Mathias Buus Madsen <m@ge.tt>", | ||
"Ian Jorgensen <i@ge.tt>" | ||
], | ||
"dependencies": { | ||
"mongodb":"1.2.x", | ||
"memolite":"~0.1.0" | ||
}, | ||
"scripts": { | ||
"test":"node ./tests" | ||
} | ||
"name": "mongojs", | ||
"description": "a simple mongo module that implements the mongo api", | ||
"keywords": [ | ||
"mongo", | ||
"db", | ||
"mongodb" | ||
], | ||
"version": "0.7.0", | ||
"repository": "git://github.com/gett/mongojs.git", | ||
"author": "Ge.tt <hello@ge.tt>", | ||
"contributors": [ | ||
"Mathias Buus Madsen <m@ge.tt>", | ||
"Ian Jorgensen <i@ge.tt>" | ||
], | ||
"dependencies": { | ||
"mongodb": "~1.2.13", | ||
"memolite": "~0.1.0", | ||
"readable-stream": "~0.3.1" | ||
}, | ||
"scripts": { | ||
"test": "node ./tests" | ||
} | ||
} |
@@ -64,3 +64,3 @@ # mongojs | ||
db.mycollection.findAndModify({ | ||
db.mycollection.findAndModify({ | ||
query: { name: 'mathias' }, | ||
@@ -96,2 +96,17 @@ update: { $set: { tag:'maintainer' } }, | ||
## Streaming cursors | ||
As of `0.7.0` all cursors are a [readable stream](http://nodejs.org/api/stream.html#stream_readable_stream) of objects. | ||
``` js | ||
var JSONStream = require('JSONStream'); | ||
// pipe all documents in mycollection to stdout | ||
db.mycollection.find({}).pipe(JSONStream.stringify()).pipe(process.stdout); | ||
``` | ||
Notice that you should pipe the cursor through a stringifier (like [JSONStream](https://github.com/dominictarr/JSONStream)) | ||
if you want to pipe it to a serial stream like a http response. | ||
## Replication Sets | ||
@@ -98,0 +113,0 @@ |
17530
20
447
119
3
+ Addedreadable-stream@~0.3.1
+ Addedreadable-stream@0.3.1(transitive)
Updatedmongodb@~1.2.13