core.medplumclient.upsertresource | Medplum
MedplumClient.upsertResource() method
Upsert a resource: update it in place if it exists, otherwise create it. This is done in a single, transactional request to guarantee data consistency.
Signature:
upsertResource<T extends Resource>(resource: T, query: QueryTypes, options?: MedplumRequestOptions): Promise<WithId<T>>;
Parameters
| Parameter | Type | Description |
|---|---|---|
| resource | T | The resource to update or create. |
| query | QueryTypes | A FHIR search query to uniquely identify the resource if it already exists. |
| options | MedplumRequestOptions | (Optional) Optional fetch options. |
Returns:
Promise< WithId
The updated/created resource.