SDK
SDK Javascript v6.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.

updateUser #

Updates a user definition.


updateUser(kuid, body, [options]);

PropertyTypeDescription
kuid
string
User kuid
body
object
User content
options
object
Query options

body #

The body contains the list of profile ids to attach the user to and potential additional information.
Any other attribute can be added. Make sure to update the user mapping collection to match your custom attributes.

Example:

{
  profileIds: [
    'default'
  ],
  firstName: 'John',
  lastName: 'Doe'
}

options #

PropertyType
(default)
Description
queuable
boolean

(true)
If true, queues the request during downtime, until connected to Kuzzle again
refresh
boolean

(false)
If set to wait_for, Kuzzle will not respond until the updated user is indexed

Resolves #

A User object containing information about the updated user.

Usage #

try {
  const response = await kuzzle.security.updateUser(
    'john.doe',
    {
      profileIds: ['default'],
      firstName: 'John',
      lastName: 'Doe'
    }
  );
  console.log(response);
  /*
  User {
    _id: 'john.doe',
    content:,
      { profileIds: [ 'default' ],
        fullName: 'John Doe',
        _kuzzle_info:
          { author: '-1',
            createdAt: 1561379086534,
            updatedAt: null,
            updater: null } } }
   */
} catch (e) {
  console.error(e);
}