Database
MongoDB, MySQL, PostgreSQL, and Redis database operations.
9 modules
| Module | Description |
|---|---|
| Masukkan Database | Sisipkan data ke tabel database |
| Kueri Database | Eksekusi kueri SQL pada database PostgreSQL, MySQL, atau SQLite |
| Perbarui Database | Perbarui data di tabel database |
| MongoDB Temukan | Kueri dokumen dari koleksi MongoDB |
| MongoDB Masukkan | Sisipkan satu atau lebih dokumen ke koleksi MongoDB |
| MySQL Kueri | Eksekusi kueri SQL pada database MySQL dan kembalikan hasil |
| PostgreSQL Kueri | Eksekusi kueri SQL pada database PostgreSQL dan kembalikan hasil |
| Redis Dapatkan | Ambil nilai dari cache Redis |
| Redis Atur | Atur nilai di cache Redis |
Modules
Masukkan Database
database.insert
Sisipkan data ke tabel database
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 | Jumlah baris yang disisipkan |
returning_data | array | Jumlah baris yang disisipkan |
Example: Insert single row
table: users
data: {"name": "John", "email": "john@example.com"}
database_type: postgresqlKueri Database
database.query
Eksekusi kueri SQL pada database PostgreSQL, MySQL, atau SQLite
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 | Baris hasil kueri |
row_count | number | Baris hasil kueri |
columns | array | Baris hasil kueri |
Example: Select with parameters
query: SELECT * FROM users WHERE status = $1
params: ["active"]
database_type: postgresqlPerbarui Database
database.update
Perbarui data di tabel database
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 | Jumlah baris yang diperbarui |
Example: Update user status
table: users
data: {"status": "active"}
where: {"id": 123}
database_type: postgresqlMongoDB Temukan
db.mongodb.find
Kueri dokumen dari koleksi 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 | Array dokumen yang cocok |
count | number | Array dokumen yang cocok |
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 Masukkan
db.mongodb.insert
Sisipkan satu atau lebih dokumen ke koleksi 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 |
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 | Jumlah dokumen yang disisipkan |
inserted_ids | array | Jumlah dokumen yang disisipkan |
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 Kueri
db.mysql.query
Eksekusi kueri SQL pada database MySQL dan kembalikan hasil
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 baris hasil sebagai objek |
row_count | number | Array baris hasil sebagai objek |
columns | array | Array baris hasil sebagai objek |
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 Kueri
db.postgresql.query
Eksekusi kueri SQL pada database PostgreSQL dan kembalikan hasil
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 baris hasil sebagai objek |
row_count | number | Array baris hasil sebagai objek |
columns | array | Array baris hasil sebagai objek |
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 Dapatkan
db.redis.get
Ambil nilai dari cache 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 | Nilai yang dikembalikan |
exists | boolean | Nilai yang dikembalikan |
key | string | Nilai yang dikembalikan |
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 Atur
db.redis.set
Atur nilai di cache 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