DetachRelation
Remove relationships between records in RushDB by specifying source ID, target IDs, and relation type to manage your graph database connections.
Instructions
Remove a relationship between records (single or multiple targets)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| direction | No | Direction of the relationship | outgoing |
| relationType | No | Type of the relationship to remove | |
| sourceId | Yes | ID of the source record | |
| targetId | No | ID of one target record (deprecated if targetIds provided) | |
| targetIds | No | IDs of multiple target records | |
| transactionId | No | Optional transaction ID for atomic relation removal |
Implementation Reference
- tools/DetachRelation.ts:17-49 (handler)The core handler function that performs the DetachRelation operation using the database API.export async function DetachRelation(params: { sourceId: string targetId?: string targetIds?: string[] relationType?: string direction?: 'outgoing' | 'incoming' | 'bidirectional' transactionId?: string }) { const { sourceId, targetId, targetIds, relationType, direction = 'outgoing', transactionId } = params const options: any = {} if (relationType) { options.typeOrTypes = relationType } if (direction) { options.direction = direction } const targets: string[] = targetIds && targetIds.length > 0 ? targetIds : targetId ? [targetId] : [] if (targets.length === 0) { return { success: false, message: 'No targetId(s) provided' } } await db.records.detach({ source: sourceId, target: targets, options }, transactionId) return { success: true, message: `Relationship detached from '${sourceId}' to ${targets.length} target record(s)` } }
- tools.ts:211-238 (schema)Defines the input schema, description, and registers DetachRelation in the tools list for MCP ListTools.{ name: 'DetachRelation', description: 'Remove a relationship between records (single or multiple targets)', inputSchema: { type: 'object', properties: { sourceId: { type: 'string', description: 'ID of the source record' }, targetId: { type: 'string', description: 'ID of one target record (deprecated if targetIds provided)' }, targetIds: { type: 'array', items: { type: 'string' }, description: 'IDs of multiple target records' }, relationType: { type: 'string', description: 'Type of the relationship to remove' }, direction: { type: 'string', enum: ['outgoing', 'incoming', 'bidirectional'], description: 'Direction of the relationship', default: 'outgoing' }, transactionId: { type: 'string', description: 'Optional transaction ID for atomic relation removal' } }, required: ['sourceId'] } },
- index.ts:239-255 (registration)Registers the tool handler in the MCP CallToolRequestSchema switch dispatcher.case 'DetachRelation': const detachResult = await DetachRelation({ sourceId: args.sourceId as string, targetId: args.targetId as string | undefined, targetIds: args.targetIds as string[] | undefined, relationType: args.relationType as string | undefined, direction: args.direction as 'outgoing' | 'incoming' | 'bidirectional' | undefined, transactionId: args.transactionId as string | undefined }) return { content: [ { type: 'text', text: detachResult.message } ] }