BulkCreateRecords
Create multiple database records simultaneously in RushDB to streamline data insertion and improve efficiency for batch operations.
Instructions
Create multiple records in a single operation
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| label | Yes | Label for all records | |
| data | Yes | Array of record data to insert | |
| transactionId | No | Optional transaction ID for atomic bulk creation |
Implementation Reference
- tools/BulkCreateRecords.ts:28-40 (handler)The main handler function implementing the BulkCreateRecords tool logic: creates multiple records using db.records.createMany within an optional transaction and returns success message with generated IDs.export async function BulkCreateRecords({ label, data, transactionId }: BulkCreateRecordsArgs): Promise<BulkCreateRecordsResult> { const result = await db.records.createMany({ label, data }, transactionId) const ids = result.data.map((record: any) => record.id()) return { message: `Successfully created ${ids.length} records with label '${label}'`, ids } }
- tools/BulkCreateRecords.ts:17-26 (schema)TypeScript type definitions for input arguments (BulkCreateRecordsArgs) and output result (BulkCreateRecordsResult) used by the handler.type BulkCreateRecordsArgs = { label: string data: Record<string, any>[] transactionId?: string } type BulkCreateRecordsResult = { message: string ids: string[] }
- tools.ts:257-269 (registration)Tool registration entry in the tools array, providing the name, description, and JSON schema for input validation in the MCP server.{ name: 'BulkCreateRecords', description: 'Create multiple records in a single operation', inputSchema: { type: 'object', properties: { label: { type: 'string', description: 'Label for all records' }, data: { type: 'array', items: { type: 'object' }, description: 'Array of record data to insert' }, transactionId: { type: 'string', description: 'Optional transaction ID for atomic bulk creation' } }, required: ['label', 'data'] } },
- index.ts:273-286 (helper)Dispatcher switch case that invokes the BulkCreateRecords handler with parsed arguments and formats the MCP response content.case 'BulkCreateRecords': const bulkCreateResult = await BulkCreateRecords({ label: args.label as string, data: args.data as Record<string, any>[], transactionId: args.transactionId as string | undefined }) return { content: [ { type: 'text', text: `${bulkCreateResult.message}\nIDs: ${bulkCreateResult.ids.join(', ')}` } ] }
- tools.ts:28-28 (registration)Includes 'BulkCreateRecords' in the ToolName type union for type safety.| 'BulkCreateRecords'