[sf-fx-runtime-nodejs](/docs/platform/functions/guide/NODE_README.md) / 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*](/docs/platform/functions/guide/unitofwork.md)): *Promise*\<Map\<string, [*RecordModificationResult*](/docs/platform/functions/guide/recordmodificationresult.md)>>

Commits a [UnitOfWork](/docs/platform/functions/guide/unitofwork.md), 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](/docs/platform/functions/guide/modules.md#referenceid) returned from [UnitOfWork.registerCreate](/docs/platform/functions/guide/unitofwork.md#registercreate) and [UnitOfWork.registerUpdate](/docs/platform/functions/guide/unitofwork.md#registerupdate).

#### Parameters

| Name         | Type                                                         | Description                                                               |
| :----------- | :----------------------------------------------------------- | :------------------------------------------------------------------------ |
| `unitOfWork` | [*UnitOfWork*](/docs/platform/functions/guide/unitofwork.md) | The [UnitOfWork](/docs/platform/functions/guide/unitofwork.md) to commit. |

**Returns:** *Promise*\<Map\<string, [*RecordModificationResult*](/docs/platform/functions/guide/recordmodificationresult.md)>>

A map of [RecordModificationResult](/docs/platform/functions/guide/recordmodificationresult.md)s, indexed by their [ReferenceId](/docs/platform/functions/guide/modules.md#referenceid)s.

***

### create

▸ **create**(`record`: [*RecordForCreate*](/docs/platform/functions/guide/modules.md#recordforcreate)): *Promise*<[*RecordModificationResult*](/docs/platform/functions/guide/recordmodificationresult.md)>

Creates a new record described by the given [RecordForCreate](/docs/platform/functions/guide/modules.md#recordforcreate).

#### Parameters

| Name     | Type                                                                           | Description                    |
| :------- | :----------------------------------------------------------------------------- | :----------------------------- |
| `record` | [*RecordForCreate*](/docs/platform/functions/guide/modules.md#recordforcreate) | The record create description. |

**Returns:** *Promise*<[*RecordModificationResult*](/docs/platform/functions/guide/recordmodificationresult.md)>

A [RecordModificationResult](/docs/platform/functions/guide/recordmodificationresult.md) that contains the created data wrapped in a Promise.

***

### delete

▸ **delete**(`type`: *string*, `id`: *string*): *Promise*<[*RecordModificationResult*](/docs/platform/functions/guide/recordmodificationresult.md)>

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

#### Parameters

| Name   | Type     | Description                              |
| :----- | :------- | :--------------------------------------- |
| `type` | *string* | The object type of the record to delete. |
| `id`   | *string* | The id of the record to delete.          |

**Returns:** *Promise*<[*RecordModificationResult*](/docs/platform/functions/guide/recordmodificationresult.md)>

A [RecordModificationResult](/docs/platform/functions/guide/recordmodificationresult.md) that contains the deleted data wrapped in a Promise.

***

### newUnitOfWork

▸ **newUnitOfWork**(): [*UnitOfWork*](/docs/platform/functions/guide/unitofwork.md)

Creates a new and empty [UnitOfWork](/docs/platform/functions/guide/unitofwork.md).

**Returns:** [*UnitOfWork*](/docs/platform/functions/guide/unitofwork.md)

An empty [UnitOfWork](/docs/platform/functions/guide/unitofwork.md).

***

### query

▸ **query**(`soql`: *string*): *Promise*<[*RecordQueryResult*](/docs/platform/functions/guide/recordqueryresult.md)>

Queries for records with a given SOQL string.

#### Parameters

| Name   | Type     | Description      |
| :----- | :------- | :--------------- |
| `soql` | *string* | The SOQL string. |

**Returns:** *Promise*<[*RecordQueryResult*](/docs/platform/functions/guide/recordqueryresult.md)>

A [RecordQueryResult](/docs/platform/functions/guide/recordqueryresult.md) that contains the queried data wrapped in a Promise.

***

### queryMore

▸ **queryMore**(`recordQueryResult`: [*RecordQueryResult*](/docs/platform/functions/guide/recordqueryresult.md)): *Promise*<[*RecordQueryResult*](/docs/platform/functions/guide/recordqueryresult.md)>

Queries for more records, based on the given [RecordQueryResult](/docs/platform/functions/guide/recordqueryresult.md).

#### Parameters

| Name                | Type                                                                       | Description                              |
| :------------------ | :------------------------------------------------------------------------- | :--------------------------------------- |
| `recordQueryResult` | [*RecordQueryResult*](/docs/platform/functions/guide/recordqueryresult.md) | The query result to query more data for. |

**Returns:** *Promise*<[*RecordQueryResult*](/docs/platform/functions/guide/recordqueryresult.md)>

A [RecordQueryResult](/docs/platform/functions/guide/recordqueryresult.md) that contains the queried data wrapped in a Promise.

***

### update

▸ **update**(`update`: [*RecordForUpdate*](/docs/platform/functions/guide/modules.md#recordforupdate)): *Promise*<[*RecordModificationResult*](/docs/platform/functions/guide/recordmodificationresult.md)>

Updates an existing record described by the given [RecordForUpdate](/docs/platform/functions/guide/modules.md#recordforupdate).

#### Parameters

| Name     | Type                                                                           | Description                    |
| :------- | :----------------------------------------------------------------------------- | :----------------------------- |
| `update` | [*RecordForUpdate*](/docs/platform/functions/guide/modules.md#recordforupdate) | The record update description. |

**Returns:** *Promise*<[*RecordModificationResult*](/docs/platform/functions/guide/recordmodificationresult.md)>

A [RecordModificationResult](/docs/platform/functions/guide/recordmodificationresult.md) that contains the updated data wrapped in a Promise.
