Skip to content

EntityMethods

Entity methods interface - defines operations that can be performed on an entity

Methods

deleteAttachment()

deleteAttachment(recordId: string, fieldName: string): Promise<EntityDeleteAttachmentResponse>

Deletes an attachment from a File-type field of an entity record

Parameters

Parameter Type Description
recordId string UUID of the record containing the attachment
fieldName string Name of the File-type field containing the attachment

Returns

Promise<EntityDeleteAttachmentResponse>

Promise resolving to EntityDeleteAttachmentResponse


deleteRecords()

deleteRecords(recordIds: string[], options?: EntityDeleteRecordsOptions): Promise<EntityDeleteResponse>

Delete data from this entity

Parameters

Parameter Type Description
recordIds string[] Array of record UUIDs to delete
options? EntityDeleteRecordsOptions Delete options

Returns

Promise<EntityDeleteResponse>

Promise resolving to delete response


downloadAttachment()

downloadAttachment(recordId: string, fieldName: string): Promise<Blob>

Downloads an attachment stored in a File-type field of an entity record

Parameters

Parameter Type Description
recordId string UUID of the record containing the attachment
fieldName string Name of the File-type field containing the attachment

Returns

Promise<Blob>

Promise resolving to Blob containing the file content


getAllRecords()

getAllRecords<T>(options?: T): Promise<T extends HasPaginationOptions<T> ? PaginatedResponse<EntityRecord> : NonPaginatedResponse<EntityRecord>>

Get all records from this entity

Type Parameters

Type Parameter Default type
T extends EntityGetRecordsByIdOptions EntityGetRecordsByIdOptions

Parameters

Parameter Type Description
options? T Query options

Returns

Promise<T extends HasPaginationOptions<T> ? PaginatedResponse<EntityRecord> : NonPaginatedResponse<EntityRecord>>

Promise resolving to query response


getRecord()

getRecord(recordId: string, options?: EntityGetRecordByIdOptions): Promise<EntityRecord>

Gets a single record from this entity by record ID

Parameters

Parameter Type Description
recordId string UUID of the record
options? EntityGetRecordByIdOptions Query options including expansionLevel

Returns

Promise<EntityRecord>

Promise resolving to the entity record


importRecords()

importRecords(file: EntityFileType): Promise<EntityImportRecordsResponse>

Imports records from a CSV file into this entity

Parameters

Parameter Type Description
file EntityFileType CSV file to import as a Blob, File, or Uint8Array

Returns

Promise<EntityImportRecordsResponse>

Promise resolving to EntityImportRecordsResponse with record counts

Example

const entity = await entities.getById(<entityId>);
const fileInput = document.getElementById('csv-input') as HTMLInputElement;
const result = await entity.importRecords(fileInput.files[0]);
console.log(`Inserted ${result.insertedRecords} of ${result.totalRecords} records`);

insertRecord()

insertRecord(data: Record<string, any>, options?: EntityInsertRecordOptions): Promise<EntityInsertResponse>

Insert a single record into this entity

Note: Data Fabric supports trigger events only on individual inserts, not on inserting multiple records. Use this method if you need trigger events to fire for the inserted record.

Parameters

Parameter Type Description
data Record<string, any> Record to insert
options? EntityInsertRecordOptions Insert options

Returns

Promise<EntityInsertResponse>

Promise resolving to the inserted record with generated record ID


insertRecords()

insertRecords(data: Record<string, any>[], options?: EntityInsertRecordsOptions): Promise<EntityBatchInsertResponse>

Insert multiple records into this entity using insertRecords

Note: Inserting multiple records do not trigger Data Fabric trigger events. Use insertRecord if you need trigger events to fire for each inserted record.

Parameters

Parameter Type Description
data Record<string, any>[] Array of records to insert
options? EntityInsertRecordsOptions Insert options

Returns

Promise<EntityBatchInsertResponse>

Promise resolving to batch insert response


queryRecords()

queryRecords<T>(options?: T): Promise<T extends HasPaginationOptions<T> ? PaginatedResponse<EntityRecord> : NonPaginatedResponse<EntityRecord>>

Queries records in this entity with filters, sorting, and SDK-managed pagination

Type Parameters

Type Parameter Default type
T extends EntityQueryRecordsOptions EntityQueryRecordsOptions

Parameters

Parameter Type Description
options? T Query options including filterGroup, selectedFields, sortOptions, and pagination

Returns

Promise<T extends HasPaginationOptions<T> ? PaginatedResponse<EntityRecord> : NonPaginatedResponse<EntityRecord>>

Promise resolving to NonPaginatedResponse without pagination options, or PaginatedResponse when pageSize, cursor, or jumpToPage are provided

Example

const entity = await entities.getById(<entityId>);
const result = await entity.queryRecords({
  filterGroup: {
    logicalOperator: LogicalOperator.And,
    queryFilters: [{ fieldName: "status", operator: QueryFilterOperator.Equals, value: "active" }]
  },
  sortOptions: [{ fieldName: "createdTime", isDescending: true }],
});
console.log(`Found ${result.totalCount} records`);

updateRecord()

updateRecord(recordId: string, data: Record<string, any>, options?: EntityUpdateRecordOptions): Promise<EntityUpdateRecordResponse>

Update a single record in this entity

Note: Data Fabric supports trigger events only on individual updates, not on updating multiple records. Use this method if you need trigger events to fire for the updated record.

Parameters

Parameter Type Description
recordId string UUID of the record to update
data Record<string, any> Key-value pairs of fields to update
options? EntityUpdateRecordOptions Update options

Returns

Promise<EntityUpdateRecordResponse>

Promise resolving to the updated record


updateRecords()

updateRecords(data: EntityRecord[], options?: EntityUpdateRecordsOptions): Promise<EntityUpdateResponse>

Update data in this entity

Note: Records updated using updateRecords will not trigger Data Fabric trigger events. Use updateRecord if you need trigger events to fire for each updated record.

Parameters

Parameter Type Description
data EntityRecord[] Array of records to update. Each record MUST contain the record Id, otherwise the update will fail.
options? EntityUpdateRecordsOptions Update options

Returns

Promise<EntityUpdateResponse>

Promise resolving to update response


uploadAttachment()

uploadAttachment(recordId: string, fieldName: string, file: EntityFileType, options?: EntityUploadAttachmentOptions): Promise<EntityUploadAttachmentResponse>

Uploads an attachment to a File-type field of an entity record

Parameters

Parameter Type Description
recordId string UUID of the record to upload the attachment to
fieldName string Name of the File-type field
file EntityFileType File to upload (Blob, File, or Uint8Array)
options? EntityUploadAttachmentOptions Optional EntityUploadAttachmentOptions (e.g. expansionLevel)

Returns

Promise<EntityUploadAttachmentResponse>

Promise resolving to EntityUploadAttachmentResponse