This documentation is for a deprecated version of JavaScript API client.
Some features and settings may be missing or their usage may have changed.
Refer to the documentation for the
latest version of JavaScript API client for up-to-date information.
Replace an existing object with an updated set of attributes.
The save method is used to redefine the entire set of an object’s attributes
(except of course its objectID).
In other words, it fully replaces an existing object.
Saving objects has the same effect as the add objects
method if you specify objectIDs for every record.
With save objects you define an object’s full set of attributes.
Attributes not specified will no longer exist.
For example, if an existing object contains attribute X,
but X is not defined in a later update call,
attribute X will no longer exist for that object.
In contrast, with partial update objects you can single out one or more attributes,
and either remove them, add them, or update their content.
Additionally, attributes that already exist but are not specified in a partial update are not impacted.
When updating large numbers of objects, or large sizes, be aware of our rate limit.
You’ll know you’ve reached the rate limit when you start receiving errors
on your indexing operations.
This can only be resolved if you wait before sending any further indexing operations.
// With JsonObjectvaljson=listOf(ObjectID("myID1")tojson{"firstname"to"Jimmie""lastname"to"Barninger"},ObjectID("myID1")tojson{"firstname"to"Warren""lastname"to"Speach"})index.replaceObjects(json)// With serializable class@Serializabledata classContact(valfirstname:String,vallastname:String,overridevalobjectID:ObjectID):Indexablevalcontacts=listOf(Contact("Jimmie","Barninger",ObjectID("myID")),Contact("Jimmie","Barninger",ObjectID("myID")))index.replaceObjects(Contact.serializer(),contacts)
// With JsonObjectvaljson=json{"firstname"to"Jimmie""lastname"to"Barninger""city"to"New York"}index.replaceObject(ObjectID("myID"),json)// With serializable class@Serializabledata classContact(valfirstname:String,vallastname:String,valcity:String,overridevalobjectID:ObjectID):Indexablevalcontact=Contact("Jimmie","Barninger","New York",ObjectID("myID"))index.replaceObject(Contact.serializer(),contact)
Replace all attributes from existing objects and send extra HTTP headers
If false, if any of the object do not contain an objectID, the method throws an error.
If true, if any of the object do not contain an objectID, the object is automatically assigned an objectID by the engine.
Only available for PHP.
objectIDKey
type: string
Optional
If specified, for each record, the objectID is set from the value of the specified key.
Only available for PHP.
requestOptions
type: key value mapping
default: No request options
Optional
A mapping of [`requestOptions`](/doc/api-client/getting-started/request-options/) to send along with the query.
objects ➔
object
An objectID needs to be specified for each object.
If the objectID exists, the record is replaced
If the objectID does not exist, a record will be created
Response
In this section we document the JSON response returned by the API.
Each language will encapsulate this response inside objects specific to the language and/or the implementation.
So the actual type in your language might differ from what is documented.