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

mongodb-queue

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongodb-queue - npm Package Compare versions

Comparing version 2.1.0 to 2.2.0

test/many.js

22

mongodb-queue.js

@@ -72,8 +72,22 @@ /**

var delay = opts.delay || self.delay
var msg = {
visible : delay ? nowPlusSecs(delay) : now(),
payload : payload,
var visible = delay ? nowPlusSecs(delay) : now()
var msgs = []
if (payload instanceof Array) {
payload.forEach(function(payload) {
msgs.push({
visible : visible,
payload : payload,
})
})
} else {
msgs.push({
visible : visible,
payload : payload,
})
}
self.col.insertOne(msg, function(err, results) {
self.col.insertMany(msgs, function(err, results) {
if (err) return callback(err)
if (payload instanceof Array) return callback(null, '' + results.insertedIds)
callback(null, '' + results.ops[0]._id)

@@ -80,0 +94,0 @@ })

2

package.json
{
"name": "mongodb-queue",
"version": "2.1.0",
"version": "2.2.0",
"description": "Message queues which uses MongoDB.",

@@ -5,0 +5,0 @@ "main": "mongodb-queue.js",

@@ -5,3 +5,3 @@ # mongodb-queue #

A really light-weight way to create queue with a nice API if you're already
A really light-weight way to create queues with a nice API if you're already
using MongoDB.

@@ -250,2 +250,11 @@

Or add multiple messages:
```js
queue.add(['msg1', 'msg2', 'msg3'], function(err, ids) {
// Messages with payloads 'msg1', 'msg2' & 'msg3' added.
// All 'id's are returned as an array, useful for logging.
})
```
You can delay individual messages from being visible by passing the `delay` option:

@@ -268,2 +277,3 @@

// You can now process the message
// IMPORTANT: The callback will not wait for an message if the queue is empty. The message will be undefined if the queue is empty.
})

@@ -424,3 +434,3 @@ ```

* [NEW] Update MongoDB API from v1 to v2 (thanks https://ithub.com/hanwencheng)
* [NEW] Update MongoDB API from v1 to v2 (thanks https://github.com/hanwencheng)

@@ -427,0 +437,0 @@ ### 1.0.1 (2015-05-25) ###

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