core.medplumclient.upsertresource
Home > @medplum/core > MedplumClient > upsertResource
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<T>;
Parameters
Parameter  | Type  | Description  | 
|---|---|---|
resource  | T  | The resource to update or create.  | 
query  | A FHIR search query to uniquely identify the resource if it already exists.  | |
options  | (Optional) Optional fetch options.  | 
Returns:
Promise<T>
The updated/created resource.