Skip to content

Commit 09b7da8

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 56e1a95 commit 09b7da8

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

Sources/Search/Models/AttributeToUpdate.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import Foundation
66
import Core
77
#endif
88

9+
@available(*, deprecated, message: "This schema is deprecated.")
910
public enum AttributeToUpdate: Codable, JSONEncodable, AbstractEncodable {
1011
case string(String)
1112
case builtInOperation(BuiltInOperation)

Sources/Search/SearchClient.swift

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2646,7 +2646,7 @@ open class SearchClient {
26462646
open func partialUpdateObject(
26472647
indexName: String,
26482648
objectID: String,
2649-
attributesToUpdate: [String: AttributeToUpdate],
2649+
attributesToUpdate: Codable,
26502650
createIfNotExists: Bool? = nil,
26512651
requestOptions: RequestOptions? = nil
26522652
) async throws -> UpdatedAtWithObjectIdResponse {
@@ -2668,7 +2668,26 @@ open class SearchClient {
26682668
// Adds new attributes to a record, or update existing ones. - If a record with the specified object ID doesn't
26692669
// exist, a new record is added to the index **if** `createIfNotExists` is true. - If the index doesn't exist yet,
26702670
// this method creates a new index. - You can use any first-level attribute but not nested attributes. If you
2671-
// specify a nested attribute, the engine treats it as a replacement for its first-level ancestor.
2671+
// specify a nested attribute, the engine treats it as a replacement for its first-level ancestor. To update an
2672+
// attribute without pushing the entire record, you can use these built-in operations. These operations can be
2673+
// helpful if you don't have access to your initial data. - Increment: increment a numeric attribute - Decrement:
2674+
// decrement a numeric attribute - Add: append a number or string element to an array attribute - Remove: remove all
2675+
// matching number or string elements from an array attribute made of numbers or strings - AddUnique: add a number
2676+
// or
2677+
// string element to an array attribute made of numbers or strings only if it's not already present - IncrementFrom:
2678+
// increment a numeric integer attribute only if the provided value matches the current value, and otherwise ignore
2679+
// the whole object update. For example, if you pass an IncrementFrom value of 2 for the version attribute, but the
2680+
// current value of the attribute is 1, the engine ignores the update. If the object doesn't exist, the engine only
2681+
// creates it if you pass an IncrementFrom value of 0. - IncrementSet: increment a numeric integer attribute only if
2682+
// the provided value is greater than the current value, and otherwise ignore the whole object update. For example,
2683+
// if you pass an IncrementSet value of 2 for the version attribute, and the current value of the attribute is 1,
2684+
// the
2685+
// engine updates the object. If the object doesn't exist yet, the engine only creates it if you pass an
2686+
// IncrementSet
2687+
// value that's greater than 0. You can specify an operation by providing an object with the attribute to update as
2688+
// the key and its value being an object with the following properties: - _operation: the operation to apply on the
2689+
// attribute - value: the right-hand side argument to the operation, for example, increment or decrement step, value
2690+
// to add or remove.
26722691
// Required API Key ACLs:
26732692
// - addObject
26742693
//
@@ -2685,7 +2704,7 @@ open class SearchClient {
26852704
open func partialUpdateObjectWithHTTPInfo(
26862705
indexName: String,
26872706
objectID: String,
2688-
attributesToUpdate: [String: AttributeToUpdate],
2707+
attributesToUpdate: Codable,
26892708
createIfNotExists: Bool? = nil,
26902709
requestOptions userRequestOptions: RequestOptions? = nil
26912710
) async throws -> Response<UpdatedAtWithObjectIdResponse> {

0 commit comments

Comments
 (0)