save

// Using callbacks (NodeJS or Web Browser)
document.save(function (error, result) {
  // called once the save action has been completed
});

// Using promises (NodeJS)
document.savePromise().then(result => {
  // called once the save action has been completed
});
document.save(new ResponseListener<Document>() {
    @Override
    public void onSuccess(Document object) {
      // called once the save action has been completed
    }

    @Override
    public void onError(JSONObject error) {
      // Handle error
    }
});
<?php

use \Kuzzle\Document;

// ...

/**
 * @var $document Document
 */

try {
  $document->save();
} catch (ErrorException $e) {

}

Saves this document into Kuzzle.

If this is a new document, this function will create it in Kuzzle and the id property will be made available.
Otherwise, this method will replace the latest version of this document in Kuzzle by the current content of this object.


save([options], [callback])

ArgumentsTypeDescription
optionsJSON ObjectOptional parameters
callbackfunctionOptional callback

Options

OptionTypeDescriptionDefault
volatileJSON ObjectAdditional information passed to notifications to other usersnull
queuablebooleanMark this request as (not) queuabletrue
refreshstringIf set to wait_for, Kuzzle will wait the persistence layer indexation to return (available with Elasticsearch 5.x and above)undefined

Return value

Returns this Document object to allow chaining.


Callback response

Resolves to this Document object once the document has been saved.