delete_json_doc_from_db
Remove a JSON document from a database by specifying its unique ID, enabling document management and cleanup in Fireproof JSON databases.
Instructions
Delete a JSON document by ID from a document database
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | No | ID of document to delete | |
| databaseName | No | name of document database to delete from |
Implementation Reference
- src/index.ts:460-482 (handler)The handler logic for the 'delete_json_doc_from_db' tool. It validates input using DeleteJsonDocFromDbArgsSchema, ensures the database exists (creating if necessary), deletes the document by ID using db.del(), and returns a success message.case "delete_json_doc_from_db": { const parsed = DeleteJsonDocFromDbArgsSchema.safeParse(args); if (!parsed.success) { throw new Error(`Invalid arguments for delete_json_doc_from_db: ${parsed.error}`); } const dbName = parsed.data.databaseName; if (!dbs[dbName]) { const newDb = fireproof(dbName); dbs[dbName] = { db: newDb }; } const db = dbs[dbName].db; await db.del(parsed.data.id); return { content: [ { type: "text", text: `Deleted document with ID: ${parsed.data.id}`, }, ], }; }
- src/index.ts:88-91 (schema)Zod schema defining the input arguments for the delete_json_doc_from_db tool: databaseName (string) and id (string). Used for validation in the handler.const DeleteJsonDocFromDbArgsSchema = z.object({ databaseName: z.string(), id: z.string(), });
- src/index.ts:172-188 (registration)Tool registration in the ListTools response, specifying name, description, and input schema (JSON Schema object).{ name: "delete_json_doc_from_db", description: "Delete a JSON document by ID from a document database", inputSchema: { type: "object", properties: { id: { type: "string", description: "ID of document to delete", }, databaseName: { type: "string", description: "name of document database to delete from", }, } }, },
- src/index.ts:176-186 (schema)JSON Schema in the tool registration for input validation, matching the Zod schema structure.type: "object", properties: { id: { type: "string", description: "ID of document to delete", }, databaseName: { type: "string", description: "name of document database to delete from", }, }