Database
MongoDB, MySQL, PostgreSQL, and Redis database operations.
9 modules
| Module | Description |
|---|---|
| データベース挿入 | データベーステーブルにデータを挿入 |
| データベースクエリ | PostgreSQL、MySQL、またはSQLiteデータベースでSQLクエリを実行 |
| データベース更新 | データベーステーブルのデータを更新 |
| MongoDB 検索 | MongoDBコレクションからドキュメントをクエリ |
| MongoDB 挿入 | MongoDBコレクションに1つ以上のドキュメントを挿入 |
| MySQL クエリ | MySQLデータベースでSQLクエリを実行して結果を返す |
| PostgreSQL クエリ | PostgreSQLデータベースでSQLクエリを実行して結果を返す |
| Redis 取得 | Redisキャッシュから値を取得 |
| Redis 設定 | Redisキャッシュに値を設定 |
Modules
データベース挿入
database.insert
データベーステーブルにデータを挿入
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 | 挿入された行数 |
returning_data | array | 挿入された行数 |
Example: Insert single row
table: users
data: {"name": "John", "email": "john@example.com"}
database_type: postgresqlデータベースクエリ
database.query
PostgreSQL、MySQL、またはSQLiteデータベースでSQLクエリを実行
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 | クエリ結果の行 |
row_count | number | クエリ結果の行 |
columns | array | クエリ結果の行 |
Example: Select with parameters
query: SELECT * FROM users WHERE status = $1
params: ["active"]
database_type: postgresqlデータベース更新
database.update
データベーステーブルのデータを更新
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 | 更新された行数 |
Example: Update user status
table: users
data: {"status": "active"}
where: {"id": 123}
database_type: postgresqlMongoDB 検索
db.mongodb.find
MongoDBコレクションからドキュメントをクエリ
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 | 一致するドキュメントの配列 |
count | number | 一致するドキュメントの配列 |
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 挿入
db.mongodb.insert
MongoDBコレクションに1つ以上のドキュメントを挿入
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 | 挿入されたドキュメント数 |
inserted_ids | array | 挿入されたドキュメント数 |
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 クエリ
db.mysql.query
MySQLデータベースでSQLクエリを実行して結果を返す
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 | オブジェクトとしての結果行の配列 |
row_count | number | オブジェクトとしての結果行の配列 |
columns | array | オブジェクトとしての結果行の配列 |
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 クエリ
db.postgresql.query
PostgreSQLデータベースでSQLクエリを実行して結果を返す
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 | オブジェクトとしての結果行の配列 |
row_count | number | オブジェクトとしての結果行の配列 |
columns | array | オブジェクトとしての結果行の配列 |
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 取得
db.redis.get
Redisキャッシュから値を取得
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 | 返された値 |
exists | boolean | 返された値 |
key | string | 返された値 |
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 設定
db.redis.set
Redisキャッシュに値を設定
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