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.

deleteDocument #

Delete a stored document, or all stored documents matching a search filter.

There is a small delay between the time a document is deleted and it being reflected in the search layer (usually a couple of seconds). That means that a document that was just deleted may still be returned by this function at first.

deleteDocument(documentId, [options], [callback]) #

ArgumentsTypeDescription
documentIdstringUnique document identifier
optionsJSON objectOptional parameters
callbackfunctionOptional callback

deleteDocument(filters, [options], [callback]) #

ArgumentsTypeDescription
filtersJSON objectFilters in ElasticSearch Query DSL format
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 array containing the ids of the deleted documents.

Usage #

// Deleting one document using callbacks (NodeJS or Web Browser)
kuzzle
  .collection('collection', 'index')
  .deleteDocument('document unique ID', function (err, res) {
    // callback called once the delete action has been completed
  });
// Deleting one document using promises (NodeJS)
kuzzle
  .collection('collection', 'index')
  .deleteDocumentPromise('document unique ID')
  .then(res => {
    // promises resolved once the delete action has been completed
  });
// Deleting multiple documents using callbacks (NodeJS or Web Browser)
kuzzle
  .collection('collection', 'index')
  .deleteDocument({filter: {equals: {title: 'foo'}}}, function (err, res) {
    // callback called once the delete with query has been completed
  });
// Deleting multiple documents using promises (NodeJS)
  kuzzle
  .collection('collection', 'index')
  .deleteDocumentPromise({filter: {equals: {title: 'foo'}}})
  .then(res => {
    // promise resolved once the delete by query has been completed
  });

Callback response:

["AVCoeBkimsySTKTfa8AX"]