This function performs an asynchronous request to the server to save or update a document of the specified type.
If the document already exists, it will be updated with the provided data; if it does not exist, a new document will be created.
The document is provided as a parameter and must adhere to the schema defined for the document type in the system.
Example
// Save or update an 'Employee' document with the given details. constemployee: BareBoneDoc = { doctype:'Employee', name:'EMP-001', employee_name:'John Doe', designation:'Senior Software Engineer', // Updated field department:'Engineering', }; constupdatedEmployee = awaitsaveDoc(employee); console.log(updatedEmployee); // Logs the saved or updated 'Employee' document
Example
// Save or update a 'Product' document with updated price. constproduct: BareBoneDoc = { doctype:'Product', name:'PRD-123', product_name:'Laptop', price:899.99, // Updated field stock:50, }; constupdatedProduct = awaitsaveDoc(product); console.log(updatedProduct); // Logs the saved or updated 'Product' document
Example
// Save or update an 'Order' document with a new total amount. constorder: BareBoneDoc = { doctype:'Order', name:'ORD-456', customer_name:'Alice Smith', order_date:'2024-09-08', total_amount:349.99, // Updated field }; constupdatedOrder = awaitsaveDoc(order); console.log(updatedOrder); // Logs the saved or updated 'Order' document
Throws
Throws an error if the request fails or if there is an issue with the document being saved.
Saves or updates a document in the database.
This function performs an asynchronous request to the server to save or update a document of the specified type. If the document already exists, it will be updated with the provided data; if it does not exist, a new document will be created. The document is provided as a parameter and must adhere to the schema defined for the document type in the system.
Example
Example
Example
Throws
Throws an error if the request fails or if there is an issue with the document being saved.