sf-fx-runtime-nodejs / DataApi

Interface: DataApi

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

Properties

accessToken

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

Methods

commitUnitOfWork

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.

Parameters

NameTypeDescription
unitOfWorkUnitOfWorkThe UnitOfWork to commit.

Returns: Promise<Map<string, RecordModificationResult>>

A map of RecordModificationResults, indexed by their ReferenceIds.


create

create(record: RecordForCreate): Promise<RecordModificationResult>

Creates a new record described by the given RecordForCreate.

Parameters

NameTypeDescription
recordRecordForCreateThe record create description.

Returns: Promise<RecordModificationResult>

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


delete

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

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

Parameters

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

newUnitOfWork(): UnitOfWork

Creates a new and empty UnitOfWork.

Returns: UnitOfWork

An empty UnitOfWork.


query

query(soql: string): Promise<RecordQueryResult>

Queries for records with a given SOQL string.

Parameters

NameTypeDescription
soqlstringThe SOQL string.

Returns: Promise<RecordQueryResult>

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


queryMore

queryMore(recordQueryResult: RecordQueryResult): Promise<RecordQueryResult>

Queries for more records, based on the given RecordQueryResult.

Parameters

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(update: RecordForUpdate): Promise<RecordModificationResult>

Updates an existing record described by the given RecordForUpdate.

Parameters

NameTypeDescription
updateRecordForUpdateThe record update description.

Returns: Promise<RecordModificationResult>

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