upsert method
void
upsert({})
Registers a record upsert request into the current batch queue.
The request will be executed as update if bodyParams
have a
valid existing record id
value, otherwise - create.
Implementation
void upsert({
Map<String, dynamic> body = const {},
Map<String, dynamic> query = const {},
List<http.MultipartFile> files = const [],
Map<String, String> headers = const {},
String? expand,
String? fields,
}) {
final enrichedQuery = Map<String, dynamic>.of(query);
enrichedQuery["expand"] ??= expand;
enrichedQuery["fields"] ??= fields;
final request = _BatchRequest(
method: "PUT",
files: files,
url: _batch.dummyClient
.buildURL(
"/api/collections/${Uri.encodeComponent(_collectionIdOrName)}/records",
enrichedQuery,
)
.toString(),
headers: headers,
body: body,
);
_batch._requests.add(request);
}