New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

mongodb-promise

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongodb-promise - npm Package Compare versions

Comparing version

to
0.0.3

23

lib/collection.js

@@ -224,22 +224,15 @@ var Q = require('q');

* Creates a cursor for a query that can be used to iterate over results from MongoDB
* @param query
* @param sort
* @param options
* @returns {promise|*|Q.promise}
* @param {Object} query
* @param {Array} sort
* @param {Object} [options]
* @returns {Cursor}
*/
Collection.prototype.find = function(query, sort, options) {
var deferred = Q.defer();
this._col.find(query, sort, options || {}, function(err, cursor) {
if(err) {
deferred.reject(err);
} else {
deferred.resolve(new Cursor(cursor));
}
});
return deferred.promise;
var _cursor = this._col.find(query, sort, options);
return new Cursor(_cursor);
};
/**
* Creates an index on the collection.
* @param fieldOrSpec
* @param options
* @param {Object} fieldOrSpec
* @param {Object} [options]
* @returns {promise|*|Q.promise}

@@ -246,0 +239,0 @@ */

@@ -5,2 +5,3 @@

exports.MongoClient = require('./mongo-client').MongoClient;
exports.Cursor = require('./cursor').Cursor;

@@ -7,0 +8,0 @@

{
"name": "mongodb-promise",
"version": "0.0.2",
"version": "0.0.3",
"description": "A mongodb-native promise library",

@@ -5,0 +5,0 @@ "main": "./lib",

@@ -45,3 +45,3 @@ mongodb-promise

// Read documents
// Read all documents
mp.MongoClient.connect("mongodb://127.0.0.1:27017/test")

@@ -63,2 +63,17 @@ .then(function(db){

// Read each document
mp.MongoClient.connect("mongodb://127.0.0.1:27017/test")
.then(function(db){
return db.collection('test')
.then(function(col) {
return col.find({a : 1}).each(function(doc) {
console.log(doc);
})
.then(function() {
db.close().then(console.log('success'));
})
})
})
.fail(function(err) {console.log(err);});
```

@@ -65,0 +80,0 @@ ## Download