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-mongodb

v0.0.18

Published

Node-RED nodes to talk to an Mongo database

Downloads

265

Readme

node-red-node-mongodb

A Node-RED node to save data in a MongoDB database.

Note : This is the same node as was in the core of Node-RED. As of v0.10.8 you will need to install it from here if still required.

Pre-requisite

To run this you need a local MongoDB server running. For details see the MongoDB site.

Install

Run the following command in your Node-RED user directory - typically ~/.node-red

    npm install node-red-node-mongodb

Usage

Nodes to save and retrieve data in a local MongoDB instance.

Input

Calls a MongoDB collection method based on the selected operator.

Find queries a collection using the msg.payload as the query statement as per the .find() function.

Optionally, you may also (via a function) set

  • a msg.projection object to constrain the returned fields,
  • a msg.sort object,
  • a msg.limit number,
  • a msg.skip number.

Count returns a count of the number of documents in a collection or matching a query using the msg.payload as the query statement.

Aggregate provides access to the aggregation pipeline using the msg.payload as the pipeline array.

You can either set the collection method in the node config or on msg.collection. Setting it in the node will override msg.collection.

See the MongoDB collection methods docs for examples.

The result is returned in msg.payload.

Output

A simple MongoDB output node. Can save, insert, update and remove objects from a chosen collection.

MongoDB only accepts objects.

Save and insert can either store msg or msg.payload. If msg.payload is selected it should contain an object. If not it will be wrapped in an object with a name of payload.

Save will update an existing object or insert a new object if one does not already exist.

Insert will insert a new object.

Update will modify an existing object or objects. The query to select objects to update uses msg.query and the update to the element uses msg.payload. Update can add an object if it does not exist or update multiple objects.

Remove will remove objects that match the query passed in on msg.payload. A blank query will delete all of the objects in the collection.

You can either set the collection method in the node config or on msg.collection. Setting it in the node will override msg.collection.

By default MongoDB creates an msg._id property as the primary key - so repeated injections of the same msg will result in many database entries. If this is NOT the desired behaviour - ie. you want repeated entries to overwrite, then you must set the msg._id property to be a constant by the use of a previous function node. This must be done at the correct level. If only writing msg.payload then payload must contain the _id property. If writing the whole msg object then it must contain an _id property.

This could be a unique constant or you could create one based on some other msg property.

Currently we do not limit or cap the collection size at all...