I have LWC to show contact records and modal to edit the records, I'm able to fetch records and editing also showing but don't know how to run query to update records, please look into my code, it will be great help.
//html
<template>
<lightning-card title="Contact Records">
<lightning-datatable data={wireContact.data} columns={columns} key-field="id" hide-checkbox-column="true" onrowaction={handleRowAction} draft-values={saveDraftValues}></lightning-datatable>
<template if:true={modalContainer}>
<section class="slds-modal slds-fade-in-open">
<div class="slds-modal__container">
<header class="slds-modal__header">
<button class="slds-button slds-button_icon slds-modal__close slds-button_icon-inverse" title="Close" onclick={closeModalAction}>
<lightning-icon icon-name="utility:close" alternative-text="close" variant="inverse" size="small" ></lightning-icon>
</button>
<h2 class="slds-text-heading_medium slds-hyphenate">Contact Record Detail</h2>
</header>
<div class="slds-modal__content slds-p-around_medium">
<table class="slds-table slds-table_bordered slds-table_col-bordered slds-table_cell-buffer">
<thead>
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Email Name</th>
<th>Phone Name</th>
</tr>
</thead>
<tbody>
<tr>
<td><lightning-input
type="text"
label="first name"
value={contactRow.FirstName}>
</lightning-input></td>
<td><lightning-input
type="text"
label="Last name"
value={contactRow.LastName}>
</lightning-input></td>
<td><lightning-input
type="Email"
label="Email"
value={contactRow.Email}>
</lightning-input></td>
<td><lightning-input
type="tel"
label="Phone"
value={contactRow.Phone}>
</lightning-input> </td>
</tr>
</tbody>
</table>
</div>
<footer class="slds-modal__footer">
<lightning-button class="slds-p-horizontal_medium" id="btn1" variant="brand" label="Close" title="Close" onclick={closeModalAction}></lightning-button>
<lightning-button class="slds-p-horizontal_medium" variant="brand" label="Save" title="Save" onclick={handleSave}></lightning-button>
</footer>
</div>
</section>
<div class="slds-backdrop slds-backdrop_open"></div>
</template>`enter code here`
</lightning-card>
</template>
[
// Apex class
public inherited sharing class LWCExampleController {
@AuraEnabled(Cacheable = true)
public static List<Contact> getContacts() {
return [SELECT Id, Name, FirstName, LastName, Phone, Email
FROM Contact
WHERE Email != null
AND Phone != null
ORDER BY CreatedDate DESC NULLS LAST limit 10];
}
@AuraEnabled(Cacheable = true)
public static void saveRecords(List <Contact> contactsToUpdate){
contactsToUpdate = [Select FirstName, LastName, Phone, Email FROM Contact];
update contactsToUpdate;
}
}