Skip to content

Commit ca24cfd

Browse files
algolia-botkai687shortcutsmillotp
committed
fix(specs): partial update operation (generated)
algolia/api-clients-automation#3486 Co-authored-by: algolia-bot <[email protected]> Co-authored-by: Kai Welke <[email protected]> Co-authored-by: shortcuts <[email protected]> Co-authored-by: Pierre Millot <[email protected]>
1 parent 20f1185 commit ca24cfd

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

packages/client_search/lib/src/api/search_client.dart

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1556,21 +1556,21 @@ final class SearchClient implements ApiClient {
15561556
);
15571557
}
15581558

1559-
/// Adds new attributes to a record, or update existing ones. - If a record with the specified object ID doesn't exist, a new record is added to the index **if** `createIfNotExists` is true. - If the index doesn't exist yet, this method creates a new index. - You can use any first-level attribute but not nested attributes. If you specify a nested attribute, the engine treats it as a replacement for its first-level ancestor.
1559+
/// Adds new attributes to a record, or update existing ones. - If a record with the specified object ID doesn't exist, a new record is added to the index **if** `createIfNotExists` is true. - If the index doesn't exist yet, this method creates a new index. - You can use any first-level attribute but not nested attributes. If you specify a nested attribute, the engine treats it as a replacement for its first-level ancestor. To update an attribute without pushing the entire record, you can use these built-in operations. These operations can be helpful if you don't have access to your initial data. - Increment: increment a numeric attribute - Decrement: decrement a numeric attribute - Add: append a number or string element to an array attribute - Remove: remove all matching number or string elements from an array attribute made of numbers or strings - AddUnique: add a number or string element to an array attribute made of numbers or strings only if it's not already present - IncrementFrom: increment a numeric integer attribute only if the provided value matches the current value, and otherwise ignore the whole object update. For example, if you pass an IncrementFrom value of 2 for the version attribute, but the current value of the attribute is 1, the engine ignores the update. If the object doesn't exist, the engine only creates it if you pass an IncrementFrom value of 0. - IncrementSet: increment a numeric integer attribute only if the provided value is greater than the current value, and otherwise ignore the whole object update. For example, if you pass an IncrementSet value of 2 for the version attribute, and the current value of the attribute is 1, the engine updates the object. If the object doesn't exist yet, the engine only creates it if you pass an IncrementSet value that's greater than 0. You can specify an operation by providing an object with the attribute to update as the key and its value being an object with the following properties: - _operation: the operation to apply on the attribute - value: the right-hand side argument to the operation, for example, increment or decrement step, value to add or remove.
15601560
///
15611561
/// Required API Key ACLs:
15621562
/// - addObject
15631563
///
15641564
/// Parameters:
15651565
/// * [indexName] Name of the index on which to perform the operation.
15661566
/// * [objectID] Unique record identifier.
1567-
/// * [attributesToUpdate] Attributes with their values. - one of types: [BuiltInOperation], [String],
1567+
/// * [attributesToUpdate] Attributes with their values.
15681568
/// * [createIfNotExists] Whether to create a new record if it doesn't exist.
15691569
/// * [requestOptions] additional request configuration.
15701570
Future<UpdatedAtWithObjectIdResponse> partialUpdateObject({
15711571
required String indexName,
15721572
required String objectID,
1573-
required Map<String, dynamic> attributesToUpdate,
1573+
required Object attributesToUpdate,
15741574
bool? createIfNotExists,
15751575
RequestOptions? requestOptions,
15761576
}) async {
@@ -1582,6 +1582,18 @@ final class SearchClient implements ApiClient {
15821582
objectID.isNotEmpty,
15831583
'Parameter `objectID` is required when calling `partialUpdateObject`.',
15841584
);
1585+
if (attributesToUpdate is Map) {
1586+
assert(
1587+
attributesToUpdate.isNotEmpty,
1588+
'Parameter `attributesToUpdate` is required when calling `partialUpdateObject`.',
1589+
);
1590+
}
1591+
if (attributesToUpdate is Map) {
1592+
assert(
1593+
attributesToUpdate.isNotEmpty,
1594+
'Parameter `attributesToUpdate ` is required when calling `partialUpdateObject`.',
1595+
);
1596+
}
15851597
final request = ApiRequest(
15861598
method: RequestMethod.post,
15871599
path: r'/1/indexes/{indexName}/{objectID}/partial'

0 commit comments

Comments
 (0)