Deletes a document from the database.

This function performs an asynchronous request to the server to delete a document of the specified type. Once a document is deleted, it is permanently removed from the database and cannot be recovered. Ensure that the document is not required for future reference before calling this function.

// Delete an 'Employee' document by its identifier.
const deleteParams: deleteParams = {
doctype: 'Employee',
docname: 'EMP-001',
};
const success = await deleteDoc(deleteParams);
console.log(success); // Logs `true` if the document was successfully deleted
// Delete a 'Product' document with a specific name.
const deleteParams: deleteParams = {
doctype: 'Product',
docname: 'PRD-123',
};
const success = await deleteDoc(deleteParams);
console.log(success); // Logs `true` if the document was successfully deleted
// Delete an 'Order' document by its identifier.
const deleteParams: deleteParams = {
doctype: 'Order',
docname: 'ORD-456',
};
const success = await deleteDoc(deleteParams);
console.log(success); // Logs `true` if the document was successfully deleted

Throws an error if the request fails or if there is an issue with deleting the document.

  • Parameters

    • params: deleteParams

      The parameters for deleting the document. This includes:

      • doctype: The document type of the document to be deleted.
      • docname: The name or identifier of the document to be deleted.

    Returns Promise<boolean>

    A promise that resolves to true if the document was successfully deleted, or false if the deletion failed.