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

monk

Package Overview
Dependencies
Maintainers
3
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

monk - npm Package Compare versions

Comparing version 3.0.7 to 3.1.0

15

History.md

@@ -0,1 +1,7 @@

3.1.0 / 2016-07-22
==================
- Add `Collection.group` (fix #63)
- Add `Collection.bulkWrite` (fix #85)
- Pipe `mongodb.Logger` to `debug` (fix #143)
3.0.7 / 2016-07-14

@@ -63,3 +69,12 @@ ==================

- Make the sort option behave like fields
- `Collection.update` now return an object:
```
{
n: number of matched documents,
nModified: number of modified documents,
nUpserted: number of upserted documents
}
```
1.0.1 / 2015-03-25

@@ -66,0 +81,0 @@ ==================

@@ -129,2 +129,33 @@ /*

/**
* Perform a bulkWrite operation without a fluent API
*
* http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#bulkWrite
*
* @param {Array} operations - Bulk operations to perform.
* @param {Object} [opts] options
* @param {Function} [fn] callback
* @return {Promise}
*/
Collection.prototype.bulkWrite = function (operations, opts, fn) {
if (typeof opts === 'function') {
fn = opts
opts = {}
}
opts = this.opts(opts)
// cast
if (opts.castIds !== false) {
operations = util.cast(operations)
}
// query
debug('%s bulkWrite %j', this.name, operations)
return this.executeWhenOpened().then(function (col) {
return col.bulkWrite(operations, opts)
}).then(thenFn(fn)).catch(catchFn(fn))
}
/**
* Returns the count of documents that would match a find() query. The db.collection.count() method does not perform the find() operation but instead counts and returns the number of results that match a query.

@@ -619,2 +650,40 @@ *

/**
* Run a group command across a collection
*
* http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#group
*
* @param {object | array | function} keys - An object, array or function expressing the keys to group by.
* @param {Object} condition - An optional condition that must be true for a row to be considered.
* @param {Object} initial - Initial value of the aggregation counter object.
* @param {Function} reduce - The reduce function aggregates (reduces) the objects iterated.
* @param {Function} [finalize] An optional function to be run on each item in the result set just before the item is returned.
* @param {boolean} [command] Specify if you wish to run using the internal group command or using eval, default is true.
* @param {Object} [opts] options
* @param {Function} [fn] callback
*
* @example
*
* users.findOneAndUpdate({ name: 'Mathieu' }, opts)
* users.findOneAndUpdate({ query: { name: 'Mathieu' }, opts)
* @return {Promise}
*/
Collection.prototype.group = function (keys, condition, initial, reduce, finalize, command, opts, fn) {
if (typeof opts === 'function') {
fn = opts
opts = {}
}
console.log(keys, condition, initial, reduce, finalize, command, opts, fn)
opts = this.opts(opts)
// query
debug('%s group %j with %j', this.name, keys, condition)
return this.executeWhenOpened().then(function (col) {
return col.group(keys, condition, initial, reduce, finalize, command, opts)
}).then(thenFn(fn)).catch(catchFn(fn))
}
/**
* Returns an array that holds a list of documents that identify and describe the existing indexes on the collection.

@@ -621,0 +690,0 @@ *

21

lib/manager.js

@@ -6,9 +6,24 @@ /*

var mongo = require('mongodb')
var debug = require('debug')('monk:manager')
var Debug = require('debug')
var monkDebug = Debug('monk:manager')
var Collection = require('./collection')
var ObjectId = mongo.ObjectID
var MongoClient = mongo.MongoClient
var Logger = mongo.Logger
var EventEmitter = require('events').EventEmitter
var inherits = require('util').inherits
/*
* Logger
*/
Logger.setCurrentLogger(function (msg, context) {
if (context.type === 'error') {
return console.error(msg)
}
var logger = Debug('mongo:' + context.className)
logger.log = console.log.bind(console)
logger(context.type.toUpperCase() + ': ' + context.message)
})
Logger.setLevel('debug') // set the level to `debug` so we have everything going through debug
var STATE = {

@@ -63,3 +78,3 @@ CLOSED: 'closed',

uri = uri.join(',') + '/' + opts.database
debug('repl set connection "%j" to database "%s"', uri, opts.database)
monkDebug('repl set connection "%j" to database "%s"', uri, opts.database)
}

@@ -77,2 +92,4 @@

this.on('open', function (db) {
monkDebug('connection opened')
monkDebug('emptying queries queue (%s to go)', this._queue.length)
this._queue.forEach(function (cb) {

@@ -79,0 +96,0 @@ cb(db)

10

lib/monk.js
/*
* Module exports.
* Module exports
*/

@@ -9,5 +9,3 @@

/*
* Expose Collection.
*
* @api public
* Expose Collection
*/

@@ -18,5 +16,3 @@

/*
* Expose util.
*
* @api public
* Expose util
*/

@@ -23,0 +19,0 @@

{
"name": "monk",
"version": "3.0.7",
"version": "3.1.0",
"main": "lib/monk.js",

@@ -5,0 +5,0 @@ "tags": [

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