update

var updateContent = {
  policies: [
    {roleId: 'myrole'},
  ]
};

// Using callbacks (NodeJS or Web Browser)
profile.update(updateContent, function(err, updatedProfile) {
  // the updatedProfile variable is the updated Profile object
})

// Using promises (NodeJS)
profile
  .updatePromise(updateContent)
  .then(updatedProfile => {
    // the updatedProfile variable is the updated Profile object
  });
JSONObject policy1 = new JSONObject().put("roleId", "myrole");

JSONObject updateContent = new JSONObject()
  .put("policies", new JSONArray().put(policy1));

profile.update(updateContent, new ResponseListener<Profile>() {
  @Override
  public void onSuccess(Profile updatedProfile) {

  }

  @Override
  public void onError(JSONObject error) {

  }
});
<?php

use Kuzzle\Security\Profile;

// ...

/*
 * @var $profile Profile
 */
$profileContent = [
  'policies' => [
    ['roleId' => 'myrole']
  ]
];

try {
  $profile->update($profileContent);
}
catch (ErrorException $e) {

}

Performs a partial content update on this object.


update(content, [options], [callback])

ArgumentsTypeDescription
contentJSON ObjectProfile content
optionsJSON ObjectOptional parameters
callbackfunctionOptional callback handling the response

Options

OptionTypeDescriptionDefault
queuablebooleanMark this request as (not) queuabletrue

Return value

Returns the Profile object to allow chaining.


Callback response

Resolves to the updated version of this object