SDK
SDK Javascript v5.x
1

You are currently looking at the documentation of a previous version of Kuzzle. We strongly recommend that you use the latest version. You can also use the version selector in the top menu.

replaceDocument #

Replace an existing document and return the updated version as a Document object.


replaceDocument(documentId, content, [options], [callback]) #

ArgumentsTypeDescription
documentIdstringUnique document identifier
contentJSON ObjectContent of the document to create
optionsJSON ObjectOptional parameters
callbackfunctionOptional callback

Options #

OptionTypeDescriptionDefault
volatileJSON ObjectAdditional information passed to notifications to other usersnull
queuablebooleanMake this request queuable or nottrue
refreshstringIf set to wait_for, Kuzzle will wait for the persistence layer to finish indexing (available with Elasticsearch 5.x and above)undefined

Return Value #

Returns the Collection object to allow chaining.


Callback Response #

Returns an updated Document object.

Usage #

// Using callbacks (NodeJS or Web Browser)
kuzzle
  .collection('collection', 'index')
  .replaceDocument('documentId', {title: 'foo', content: 'bar'}, function (error, result) {
    // result is a Document object
  });
// Using promises (NodeJS)
kuzzle
  .collection('collection', 'index')
  .replaceDocumentPromise('documentId', {title: 'foo', content: 'bar'})
  .then(result => {
    // result is a Document object
  });