nyno-sql-insert
nyno-sql-insert — Insert JSON data into a PostgreSQL database
Description
- step: nyno-sql-insert
args:
- '${JSON}'
The nyno-sql-insert step inserts JSON data into a PostgreSQL database table (json_storage) as a jsonb column.
- Accepts a string or object as input; objects are automatically JSON-encoded before insertion.
- Stores the database response in workflow context (
${prev}by default).
Usage in a workflow YAML:
workflow:
- step: nyno-sql-insert
args:
- { "user": "Alice", "action": "login", "timestamp": "2025-12-27T12:00:00Z" }
Parameters
| Parameter | Type | Description |
|---|---|---|
payload |
string or object |
The JSON data to insert. Objects are automatically serialized to JSON strings. |
Context requirements / environment:
- PostgreSQL connection variables must exist in
./envs/.nyno_log_db.env:
Return Values
- Returns
0on success. - The database query response object is stored in
${prev}:
{
"command": "INSERT",
"rowCount": 1,
"oid": 0,
"rows": [],
"fields": [...]
}
- On failure (e.g., database connection issues), the step throws an exception.
Behavior
- Inserts JSON data into the
json_storagetable in PostgreSQL. - If the input is an object, it is automatically converted to JSON before insertion.
- Outputs the raw query result in context for downstream steps.
Examples
Example #1 — Insert simple object
workflow:
- step: nyno-sql-insert
args:
- { "user": "Bob", "action": "logout", "timestamp": "2025-12-27T12:05:00Z" }
Stores the insert response in ${prev}.
Example #2 — Insert JSON string
workflow:
- step: nyno-sql-insert
args:
- '{"event":"signup","user":"Charlie","plan":"Pro"}'
Notes
- Table
json_storagemust exist in the database with a columndataof typejsonb. - This step only performs inserts; update or query operations require separate steps.
- Use
${prev}to access the database response in downstream workflow steps.
See Also
- nyno-file-write: Save JSON data to a file.
- nyno-sql: Query data from PostgreSQL.