npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-red-contrib-mongodb3

v2.0.1

Published

MongoDB 3 driver node for Node-RED

Downloads

2,215

Readme

node-red-contrib-mongodb3

MongoDB node driver 3.0 interface for Node-RED

based on node-red-bluemix-nodes and MongoDB 3 Driver

Please refer to the mongoDB node driver 'Collection' documentation to read about each operation.

Usage

msg.payload -

  • To pass a single parameter to an operation use msg.payload as your parameter (eg {_id: 1243})
  • To pass multiple parameters to an operation fill msg.payload with an array
  • If you want to pass a single parameter WHICH IS AN ARRAY (eg as with InserMany), wrap your array in an outer array: msg.payload = [[{_id: 1243}, {_id: 2345}]]

Passing the last operation parameter (callbak) is not supported, and will be stripped if provided.

URI - Using a single URI field allows you to specify Host, Port and Database configuration as well as all other features that are supported by the MongoClient.connect, such as Mongos Proxy Connection and Replicaset Server Connection - more information can be found here. Notice that the Username & Password fields did remain. They will still be saved as Node-RED credentials (i.e. kept private). If the Username is not empty or the Password is not empty, they will be escaped and added the the URI after the mongodb:// prefix (separated by ':' and with a '@' after them). You can also leave these fields empty and enter the credentials directly in the URI, following the standard syntax: mongodb://youruser:[email protected]:27017,host2.yourmongoprovider.com:27017/yourdb?replicaSet=foo. Do not enter your credentials both in the URI and the Username & Password fields - this will create an invalid URI such as: mongodb://youruserfromfield:yourpasswordformfield@youruserfromuri:[email protected]:27017,host2.yourmongoprovider.com:27017/yourdb?replicaSet=foo.

specifying authentication database - most recent deployments of mongoDB store user credentials in a separate databse (usually admin) rather than allongside the data in each Db. Therefore you will likley need to provide a authSource parameter in your URI eg: mongodb://host1.yourmongoprovider.com:27017/yourdb?ssl=true&authSource=admin&replicaSet=foo

Parallelism Limit - Sending a lot of commands in a short time to the underlying mongodb-native driver, without waiting for their response, may cause serious problems and slow down the whole app. This has probably something to do with the connection sockets being clogged and their cache getting filled. This option allows to limit the number of operations that are sent before getting a response. For example, if the parallelism-limit is set to 5 and we are making 7 operations in a short period of time, the first 5 operations will start immediately, but the 6th and 7th operations will wait in a queue. The 6th operation will start only when one of the first 5 operations has finished. Similarly, the 7th operation will start only when another operation has finished.

db & collection operations - These operations will simply pass the db/collection instance, so they can be used directly (for example, in function nodes). The db instance is the same one that node-red-contrib-mongodb3 caches and shares between all relevant nodes - if you disconnect it, all the other mongodb3 nodes will fail. Furthermore, the parallelism-limit does not consider the future operations that you will do with the db/collection instances. However, if there are many parallel operations, requesting the db/collection will block until some of these operations finish.

Change Log

2.0

BREAKING CHANGES : driver response props are now (correctly) added to message.payload, thus chaning the response shape see https://github.com/ozomer/node-red-contrib-mongodb2/issues/34

1.0 message shape:

msg
|_  payload
     |_ ok
     |_ n
     |_ opTime
     |_ electionId     
     |_ operationTime
     |_ "$clusterTime

2.0 message shape (example for find()):

msg
|_  payload
     |_ insertedCount
     |_ ops
     |_ insertedIds      
     |_ result
            |_ ok
            |_ n
            |_ opTime
            |_ electionId
            |_ operationTime
            |_ "$clusterTime

Original creation 1.0.0

MongoDB 3 driver is originally based on MongoDB 2 driver node for Node-RED, and therefore is placed in the same github repository: (https://github.com/ozomer/node-red-contrib-mongodb2) The very-similar MongoDB 2 driver is in the same git repository, under the node-red-contrib-mongodb2 branch (not the master branch).