Create/Update/Delete

When operating on single records, DML operation can be preformed via an instance method.

insert(opts?)

import { Account } from './generated';

// properties can be set during construction
const acc = new Account({
   name: 'hello world'
});

await acc.insert();
console.log(acc.id); // will be set

After operation complete, the id property will automatically be set.

KEY

TYPE

DESCRIPTION

refresh

boolean

if true, ALL direct properties of object will be retrieved AFTER the operation complete. This is done via the Composite API so no additional requests are consumed. Defaults to false

update(opts?)

const acc = (await Account.retrieve(
  'SELECT Id, Name FROM Account LIMIT 1'
))[0]

acc.name = 'Acme';
await acc.update();

KEY

TYPE

DESCRIPTION

refresh

boolean

if true, ALL direct properties of object will be retrieved AFTER the operation complete. This is done via the Composite API so no additional requests are consumed. Defaults to false

sendAllFields

boolean

Sends ALL fields to Salesforce, regardless of if the property has been modified. Defaults to false

delete()

//...
await acc.delete();

Last updated

Was this helpful?