When to use Apex over LDS functions?
Harshita Khandelwal
Sr. Application Engineer at Uber | 20x Certified Salesforce Application Architect
Have you ever been stuck on deciding to choose in between LDS functions and Apex methods? Let's answer this dilemma
If you come across a situation where you need to update more than one records in the database that needs to be updated all or none then I would suggest Apex methods over LDS.
Why? Apex supports transactions that will rollback all other DMLs if any one of the DML fails. That support I did not come across in LDS. In LDS, every function runs in separate transactions. For other simpler tasks LDS is great.
Note: LDS means Lightning Data Service, LDS functions are also known as wire adaptors.
Salesforce UI Architect | Full Stack Developer | JavaScript, TypeScript, NextJS, React | Omnistudio | LWC | Node.js | Responsiveness | Accessibility | Testing | Automation | Performance Optimization
4 年What about uiRecordApi?