Database
MongoDB, MySQL, PostgreSQL, and Redis database operations.
9 modules
| Module | Description |
|---|---|
| Database Insert | Insert data into database tables |
| Database Query | Execute SQL queries on PostgreSQL, MySQL, or SQLite databases |
| Database Update | Update data in database tables |
| MongoDB Find | Query documents from MongoDB collection |
| MongoDB Insert | Insert one or more documents into MongoDB collection |
| MySQL Query | Execute a SQL query on MySQL database and return results |
| PostgreSQL Query | Execute a SQL query on PostgreSQL database and return results |
| Redis Get | Get a value from Redis cache |
| Redis Set | Set a value in Redis cache |
Modules
Database Insert
database.insert
Insert data into database tables
Parameters:
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
table | string | Yes | - | Name of the table |
data | object | Yes | - | Data to insert or update |
database_type | select (postgresql, mysql, sqlite) | No | postgresql | Database type to connect to |
connection_string | string | No | - | Database connection string |
host | string | No | - | Database host |
port | number | No | - | Database port |
database | string | No | - | Database name |
user | string | No | - | Database username |
password | string | No | - | Database password |
returning | array | No | - | Columns to return after insert (PostgreSQL) |
Output:
| Field | Type | Description |
|---|---|---|
inserted_count | number | Number of rows inserted |
returning_data | array | Number of rows inserted |
Example: Insert single row
table: users
data: {"name": "John", "email": "john@example.com"}
database_type: postgresqlDatabase Query
database.query
Execute SQL queries on PostgreSQL, MySQL, or SQLite databases
Parameters:
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
query | string | Yes | - | SQL query to execute |
params | array | No | [] | Parameters for parameterized queries (prevents SQL injection) |
database_type | select (postgresql, mysql, sqlite) | No | postgresql | Database type to connect to |
connection_string | string | No | - | Database connection string |
host | string | No | - | Database host |
port | number | No | - | Database port |
database | string | No | - | Database name |
user | string | No | - | Database username |
password | string | No | - | Database password |
fetch | select (all, one, none) | No | all | How many rows to return from the query |
Output:
| Field | Type | Description |
|---|---|---|
rows | array | Query result rows |
row_count | number | Query result rows |
columns | array | Query result rows |
Example: Select with parameters
query: SELECT * FROM users WHERE status = $1
params: ["active"]
database_type: postgresqlDatabase Update
database.update
Update data in database tables
Parameters:
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
table | string | Yes | - | Name of the table |
data | object | Yes | - | Data to insert or update |
where | object | Yes | - | WHERE conditions (column: value for equality) |
database_type | select (postgresql, mysql, sqlite) | No | postgresql | Database type to connect to |
connection_string | string | No | - | Database connection string |
host | string | No | - | Database host |
port | number | No | - | Database port |
database | string | No | - | Database name |
user | string | No | - | Database username |
password | string | No | - | Database password |
Output:
| Field | Type | Description |
|---|---|---|
updated_count | number | Number of rows updated |
Example: Update user status
table: users
data: {"status": "active"}
where: {"id": 123}
database_type: postgresqlMongoDB Find
db.mongodb.find
Query documents from MongoDB collection
Parameters:
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
connection_string | string | No | - | MongoDB connection string (defaults to env.MONGODB_URL) |
database | string | Yes | - | Database name |
collection | string | Yes | - | Collection name |
filter | object | No | {} | MongoDB query filter (empty object {} returns all) |
projection | object | No | - | Fields to include/exclude in results |
limit | number | No | 100 | Maximum number of documents to return |
sort | object | No | - | Sort order (1 for ascending, -1 for descending) |
Output:
| Field | Type | Description |
|---|---|---|
documents | array | Array of matching documents |
count | number | Array of matching documents |
Example: Find all active users
database: myapp
collection: users
filter: {"status": "active"}
limit: 50Example: Find with projection and sort
database: myapp
collection: orders
filter: {"total": {"$gt": 100}}
projection: {"_id": 0, "order_id": 1, "total": 1, "created_at": 1}
sort: {"created_at": -1}
limit: 20MongoDB Insert
db.mongodb.insert
Insert one or more documents into MongoDB collection
Parameters:
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
connection_string | string | No | - | MongoDB connection string (defaults to env.MONGODB_URL) |
database | string | Yes | - | Database name |
collection | string | Yes | - | Collection name |
document | object | No | - | Document to insert (for single insert) |
documents | array | No | - | Array of documents to insert (for bulk insert) |
Output:
| Field | Type | Description |
|---|---|---|
inserted_count | number | Number of documents inserted |
inserted_ids | array | Number of documents inserted |
Example: Insert single document
database: myapp
collection: users
document: {"name": "John Doe", "email": "john@example.com", "created_at": "${timestamp}"}Example: Insert multiple documents
database: myapp
collection: products
documents: [{"name": "Product A", "price": 19.99}, {"name": "Product B", "price": 29.99}]MySQL Query
db.mysql.query
Execute a SQL query on MySQL database and return results
Parameters:
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
host | string | No | - | Database host |
port | number | No | 3306 | Database port |
user | string | No | - | Database username |
password | string | No | - | Database password |
database | string | No | - | Database name |
query | string | Yes | - | SQL query to execute |
params | array | No | [] | Parameters for parameterized queries (prevents SQL injection) |
Output:
| Field | Type | Description |
|---|---|---|
rows | array | Array of result rows as objects |
row_count | number | Array of result rows as objects |
columns | array | Array of result rows as objects |
Example: Select products
query: SELECT id, name, price FROM products WHERE stock > 0 ORDER BY price DESC LIMIT 20Example: Parameterized query
query: SELECT * FROM orders WHERE customer_id = %s AND created_at > %s
params: ["${customer_id}", "2024-01-01"]PostgreSQL Query
db.postgresql.query
Execute a SQL query on PostgreSQL database and return results
Parameters:
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
connection_string | string | No | - | Database connection string |
query | string | Yes | - | SQL query to execute |
params | array | No | [] | Parameters for parameterized queries (prevents SQL injection) |
Output:
| Field | Type | Description |
|---|---|---|
rows | array | Array of result rows as objects |
row_count | number | Array of result rows as objects |
columns | array | Array of result rows as objects |
Example: Select users
query: SELECT id, email, created_at FROM users WHERE active = true LIMIT 10Example: Parameterized query
query: SELECT * FROM orders WHERE user_id = $1 AND status = $2
params: ["${user_id}", "completed"]Redis Get
db.redis.get
Get a value from Redis cache
Parameters:
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
key | string | Yes | - | Redis key |
host | string | No | - | Redis host (from env.REDIS_HOST or explicit) |
port | number | No | 6379 | Redis port |
db | number | No | 0 | Redis database number |
Output:
| Field | Type | Description |
|---|---|---|
value | any | The returned value |
exists | boolean | The returned value |
key | string | The returned value |
Example: Get cached value
key: user:123:profile
host: ${env.REDIS_HOST}Example: Get from remote Redis
key: session:abc
host: redis.example.com
port: 6379
db: 1Redis Set
db.redis.set
Set a value in Redis cache
Parameters:
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
key | string | Yes | - | Redis key |
value | any | Yes | - | Value to store |
ttl | number | No | - | Time to live in seconds (optional) |
host | string | No | - | Redis host (from env.REDIS_HOST or explicit) |
port | number | No | 6379 | Redis port |
db | number | No | 0 | Redis database number |
Output:
| Field | Type | Description |
|---|---|---|
success | boolean | Whether the operation completed successfully |
key | string | Key identifier |
Example: Cache user profile
key: user:123:profile
value: {"name": "John", "email": "john@example.com"}
ttl: 3600Example: Set session data
key: session:abc
value: active
ttl: 1800
host: redis.example.com