sf-fx-runtime-nodejs / DataApi

Interface: DataApi

Data API client to interact with data in a Salesforce org.

The access token used by this API client. Can be used to initialize a third-party API client or to perform custom API calls with a HTTP library.

Readonly accessToken: string

commitUnitOfWork(unitOfWork: UnitOfWork): Promise<Map<string, RecordModificationResult>>

Commits a UnitOfWork, executing all operations registered with it. If any of these operations fail, the whole unit is rolled back. To examine results for a single operation, inspect the returned map (which is keyed with ReferenceId returned from UnitOfWork.registerCreate and UnitOfWork.registerUpdate.

NameTypeDescription
unitOfWorkUnitOfWorkThe UnitOfWork to commit.

Returns: Promise<Map<string, RecordModificationResult>>

A map of RecordModificationResults, indexed by their ReferenceIds.


create(record: RecordForCreate): Promise<RecordModificationResult>

Creates a new record described by the given RecordForCreate.

NameTypeDescription
recordRecordForCreateThe record create description.

Returns: Promise<RecordModificationResult>

A RecordModificationResult that contains the created data wrapped in a Promise.


delete(type: string, id: string): Promise<RecordModificationResult>

Deletes a record, based on the given type and id.

NameTypeDescription
typestringThe object type of the record to delete.
idstringThe id of the record to delete.

Returns: Promise<RecordModificationResult>

A RecordModificationResult that contains the deleted data wrapped in a Promise.


newUnitOfWork(): UnitOfWork

Creates a new and empty UnitOfWork.

Returns: UnitOfWork

An empty UnitOfWork.


query(soql: string): Promise<RecordQueryResult>

Queries for records with a given SOQL string.

NameTypeDescription
soqlstringThe SOQL string.

Returns: Promise<RecordQueryResult>

A RecordQueryResult that contains the queried data wrapped in a Promise.


queryMore(recordQueryResult: RecordQueryResult): Promise<RecordQueryResult>

Queries for more records, based on the given RecordQueryResult.

NameTypeDescription
recordQueryResultRecordQueryResultThe query result to query more data for.

Returns: Promise<RecordQueryResult>

A RecordQueryResult that contains the queried data wrapped in a Promise.


update(update: RecordForUpdate): Promise<RecordModificationResult>

Updates an existing record described by the given RecordForUpdate.

NameTypeDescription
updateRecordForUpdateThe record update description.

Returns: Promise<RecordModificationResult>

A RecordModificationResult that contains the updated data wrapped in a Promise.