node-red-cosmos-r2 2.1.0

A Node-RED custom node that connects to a Cosmos DB and performs create, update, read, delete, and upsert operations.

npm install node-red-cosmos-r2

node-red-cosmos-r2

A Node-RED custom node that connects to a Cosmos DB and performs create, update, read, delete, and upsert operations.

Installation

Install the node-red-cosmos-r2 node from the command line:

npm install node-red-cosmos-r2

Then, restart your Node-RED instance to load the new node.

Features

  • Connect to Cosmos DB using URI, Key, Database ID, and Container ID
  • Perform create, read, update, delete, and upsert operations
  • Configure operations using input messages

Usage

Add the cosmos-r2 node to your Node-RED flow and configure it with the following properties:

  • Name: (Optional) A custom name for the node
  • URI: The Cosmos DB endpoint URI
  • Key: The Cosmos DB key
  • Database ID: The Cosmos DB database ID
  • Container ID: The Cosmos DB container ID

The input message must contain the following properties:

  • operation: The type of operation to perform, either "create", "read", "update", "delete", or "upsert"
  • item: (Optional) The item to create, update, delete, or upsert. Required for "create", "update", "delete", and "upsert" operations
  • query: (Optional) A query to filter items for "read" operation. If not provided, all items will be retrieved

The output message will contain the following property:

  • payload: The result of the operation, such as created, read, updated, deleted, or upserted items

Examples

Create an item:

{
  "operation": "create",
  "item": {
    "id": "1",
    "name": "Example Item"
  }
}

Read items:

{
  "operation": "read",
  "query": "SELECT * FROM c WHERE c.name = 'Example Item'"
}

Update an item:

{
  "operation": "update",
  "item": {
    "id": "1",
    "name": "Updated Item"
  }
}

Delete an item:

{
  "operation": "delete",
  "item": {
    "id": "1"
  }
}

Upsert an item:

{
  "operation": "upsert",
  "item": {
    "id": "1",
    "name": "Upserted Item"
  }
}

Developer Tools

A Dockerfile and sample flow are provided to test the functionality of the module.

Prerequisites

  • Docker
  • npm

Installation

  1. Install module dependencies:

    cd {path/to/repo}
    npm install
    
  2. Create Docker container:

    cd ./development_tools/docker
    docker-compose up
    
  3. Access the Node-RED flow at http://localhost:1880/.

License

GPL 3.0

Node Info

Version: 2.1.0
Updated 1 week ago
License: GPL 3.0
Rating: 5.0 1

Categories

Actions

Rate:

Downloads

6 in the last week

Nodes

  • cosmos-r2

Keywords

  • node-red
  • cosmos
  • database
  • r2