create
Add new records to SurrealDB tables with automatic ID generation, timestamp management, and schema validation.
Instructions
Create a new record in a SurrealDB table with the specified data.
This tool creates a new record with an auto-generated ID. The system will automatically:
Generate a unique ID for the record
Add created/updated timestamps
Validate the data against any defined schema
Args: table: The name of the table to create the record in (e.g., "user", "product") data: A dictionary containing the field values for the new record. Examples: - {"name": "Alice", "email": "alice@example.com", "age": 30} - {"title": "Laptop", "price": 999.99, "category": "electronics"} namespace: Optional SurrealDB namespace override. If not provided, uses SURREAL_NAMESPACE env var. database: Optional SurrealDB database override. If not provided, uses SURREAL_DATABASE env var.
Returns: A dictionary containing: - success: Boolean indicating if creation was successful - data: The created record including its generated ID and timestamps - id: The ID of the newly created record (convenience field) - error: Error message if creation failed (only present on failure)
Examples: >>> await create("user", {"name": "Alice", "email": "alice@example.com"}) { "success": true, "data": {"id": "user:ulid", "name": "Alice", "email": "alice@example.com", "created": "2024-01-01T10:00:00Z"}, "id": "user:ulid" }
Note: If you need to specify a custom ID, use the 'upsert' tool instead.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| table | Yes | ||
| data | Yes | ||
| namespace | No | ||
| database | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||