insert
Insert multiple records into a database table in a single operation. This bulk insert tool creates many records at once with auto-generated IDs, timestamps, and schema validation for efficient data management.
Instructions
Insert multiple records into a table in a single operation.
This tool is optimized for bulk inserts when you need to create many records at once. It's more efficient than calling 'create' multiple times. Each record will get:
An auto-generated unique ID
Automatic created/updated timestamps
Schema validation (if defined)
Args: table: The name of the table to insert records into (e.g., "user", "product") data: Array of dictionaries, each representing a record to insert. Example: [ {"name": "Alice", "email": "alice@example.com"}, {"name": "Bob", "email": "bob@example.com"}, {"name": "Charlie", "email": "charlie@example.com"} ]
Returns: A dictionary containing: - success: Boolean indicating if insertion was successful - data: Array of all inserted records with their generated IDs - count: Number of records successfully inserted - error: Error message if insertion failed (only present on failure)
Examples: >>> await insert("user", [ ... {"name": "Alice", "role": "admin"}, ... {"name": "Bob", "role": "user"} ... ]) { "success": true, "data": [ {"id": "user:ulid1", "name": "Alice", "role": "admin", "created": "..."}, {"id": "user:ulid2", "name": "Bob", "role": "user", "created": "..."} ], "count": 2 }
Note: For single record creation, use the 'create' tool instead.
Input Schema
Name | Required | Description | Default |
---|---|---|---|
data | Yes | ||
table | Yes |