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.

updateSpecifications #

Update parts of a specification, by replacing some fields or adding new ones.
Note that you cannot remove fields this way: missing fields will simply be left unchanged.


updateSpecifications(content, [options], [callback]) #

ArgumentsTypeDescription
contentJSON objectContent of the specification to update
optionsJSON objectOptional parameters
callbackfunctionOptional callback

Options #

OptionTypeDescriptionDefault
queuablebooleanMake this request queuable or nottrue
refreshstringIf set to wait_for, Kuzzle will wait the persistence layer to finish indexing (available with Elasticsearch 5.x and above)undefined
retryOnConflictintNumber of retries to attempt before rejecting this update because of a cluster sync conflict0

Return Value #

Returns the Collection object to allow chaining.

Usage #

var specifications = {
  strict: 'true',
  fields: {
    foo: {
      mandatory: true,
      type: 'string',
      defaultValue: 'bar'
    }
  }
};
// Using callbacks (NodeJS or Web Browser)
kuzzle
  .collection('collection', 'index')
  .updateSpecifications(specifications, function (err, res) {
    // result is a JSON object
  });
// Using promises (NodeJS)
kuzzle
  .collection('collection', 'index')
  .updateSpecificationsPromise(specifications)
  .then(res => {
    // result is a JSON object
  });

Callback response

{
  "index": {
    "collection": {
      "strict": "true",
      "fields": {
        "foo": {
          "mandatory": "true",
          "type": "string",
          "defaultValue": "bar"
        }
      }
    }
  }
}