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-orm-db

v1.0.2

Published

ORM for Oracle, Postgres, MySQL, MariaDB, SQLite and SQL Server, and more

Downloads

277

Readme

This Node-RED node allows you to perform database queries using the Sequelize ORM. It supports all basic database operations through an intuitive graphical interface, eliminating the need to write any SQL code.

ORM tool for Postgres, MySQL, MariaDB, SQLite, Microsoft SQL Server, Oracle Database, Amazon Redshift and Snowflake’s Data Cloud. It features solid transaction support, relations, eager and lazy loading, read replication and more.

Install

npm install node-red-contrib-orm-db

You'll also have to manually install the driver for your database of choice:

$ npm install --save pg pg-hstore # Postgres
$ npm install --save mysql2
$ npm install --save mariadb
$ npm install --save sqlite3
$ npm install --save tedious # Microsoft SQL Server
$ npm install --save oracledb # Oracle Database

Outputs

  1. Standard output :payload (object) : the standard output of the operation.
  2. Standard error : payload (string) : the standard error of the operation.

Details

The first step to using the node is to create the database connections and the models (database tables) to be used, and then proceed to perform all database operations. msg.payload is used as the payload of the published message.

Operation Types

  1. Raw: When queries are very complex and you can't handle them with the graphical interface, you can use this type of node to make direct queries to the database in SQL language. It has a 'Data' field that allows variable replacements in the query; refer to the Sequelize documentation for more details Raw Queries. It's important to mention that it only supports replacements and not 'Bind Parameters'.
  2. Find All: Searches in the selected model for all elements of the table. It allows filtering the information by including a 'Where' clause where the expressions can be dynamic fields passed in the input messages. If the 'Attributes' input does not have any fields selected, it will select all fields of the table. The 'Limit' and 'Offset' inputs will not be functional while set to 'false'; otherwise, they can be used with dynamic data from the input messages.
  3. Find and Count All: Same as the previous one, but the result adds the total number of elements that meet the filtering criteria, if any.
  4. Find One: Finds the first element that meets the filtering criteria in the 'Where' clause. If the 'Attributes' input does not have any fields selected, it will select all fields of the table.
  5. Add: Allows adding elements to a table according to the selected model. The 'Data' input is used to configure the source of the data to be added, which can come from the input message in the node.
  6. Update: Allows updating elements in a table according to the selected model. The 'Data' input is used to configure the source of the data to be updated, which can come from the input message in the node. You can specify the elements you want to update using the 'Where' input.
  7. Delete: Deletes elements from a table according to the selected model. It is possible to include filtering according to the 'Where' input.
  8. Count: Counts the elements in a table. It is also possible to include filtering by adding elements to the 'Where' input.
  9. Sum: Sums the elements in a table according to the selected model. The 'Attributes' input allows you to select the field of the model on which the sum operation will be performed. It is also possible to filter data using the 'Where' input.
  10. Min: Selects the minimum element from a table according to the selected model. The 'Attributes' input allows you to select the field of the model on which the minimum operation will be performed. It is also possible to filter data using the 'Where' input.
  11. Max: Selects the maximum element from a table according to the selected model. The 'Attributes' input allows you to select the field of the model on which the maximum operation will be performed. It is also possible to filter data using the 'Where' input.
  12. Begin Transaction: Transactions in relational databases are of utmost importance for data integrity. This type of node allows you to start a database transaction. It has only one output port, leaving the input message to the node unchanged and adding the variable msg.transaction with the transaction identifier. It is important to clarify that transactions should only be used with operations that make changes to the database, such as 'add', 'update', and 'delete'. For other operations, transactions have no effect.
  13. Commit Transaction: Completes the transaction when the operations of previous nodes are successful.
  14. Rollback Transaction: Completes the transaction when the operations of previous nodes result in an error.
  15. Synchronize Tables: After creating the connections and models, you can synchronize the models with the database using this type of node. There are three ways to synchronize the models with the database; refer to the Sequelize documentation Sequelize Model Synchronization. Using the node is optional since you may already have the database created, and its use in production can be very dangerous. When you use a node of this type, it has an input port which you can call from an 'inject' node, and it has two output ports: the first is used to indicate that the synchronization was successful, and the second for errors.

References