Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mongojs

Package Overview
Dependencies
Maintainers
2
Versions
105
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongojs - npm Package Compare versions

Comparing version 0.6.4 to 0.7.0

tests/test-streaming-cursor.js

8

index.js
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);

39

package.json
{
"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 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc