JavaScriptWebWebNode.jsPhoneGapReactReduxTitaniumVueJavaScript V4 Objects API Reference for Realtime Apps

This page describes the new Objects v2. To upgrade from Objects v1, refer to the migration guide.

Objects provides easy-to-use, serverless storage for user and channel data you need to build innovative, reliable, scalable applications. Use Objects to easily store metadata about your application users and channels, and their membership associations, without the need to stand up your own databases.

PubNub also triggers events when object data is set or removed from the database. Clients can receive these events in realtime and update their front-end application accordingly.

Returns a paginated list of UUID Metadata objects, optionally including the custom data object for each.

To Get All UUID Metadata you can use the following method(s) in the JavaScript V4 SDK:

  1. ParameterTypeRequiredDefaultsDescription
    includeObjectOptionalInclude respective additional fields in the response.
    totalCountBooleanOptionalfalseRequest totalCount to be included in paginated response. By default, totalCount is omitted.
    customFieldsBooleanOptionalfalseWhether to fetch custom fields or not.
    filterStringOptionalExpression used to filter the results. Only objects whose properties satisfy the given expression are returned. The filter language is defined here.
    sortObjectOptionalKey-value pair of a property to sort by, and a sort direction. Available options are id, name, and updated.

    Use asc or desc to specify sort direction, or specify null to take the default sort direction (ascending).

    For example: {name: 'asc'}
    limitNumberOptional100Number of objects to return in response. Default is 100, which is also the maximum value.
    pageObjectOptionalUse for pagination.
    nextStringOptionalPreviously-returned cursor bookmark for fetching the next page.
    prevStringOptionalPreviously-returned cursor bookmark for fetching the previous page. Ignored if you also supply the start parameter.
    callback(result) => voidOptionalCallback to the function. If not passed, the function will return a Promise instead.
pubnub.objects.getAllUUIDMetadata();
{
    "status": 200,
    "data": [
        {
            "id": "uuid-1",
            "name": "John Doe",
            "externalId": null,
            "profileUrl": null,
            "email": "johndoe@pubnub.com",
            "custom": null,
            "updated": "2019-02-20T23:11:20.893755",
            "eTag": "MDcyQ0REOTUtNEVBOC00QkY2LTgwOUUtNDkwQzI4MjgzMTcwCg=="
        },
        {
            "id": "uuid-2",
            "name": "Bob Cat",
            "externalId": null,
            "profileUrl": null,
            "email": "bobc@example.com",
            "custom": {
                "phone": "999-999-9999"
            },
            "updated": "2019-02-21T03:29:00.173452",
            "eTag": "QkRENDA5MjItMUZCNC00REI5LUE4QTktRjJGNUMxNTc2MzE3Cg=="
        }
    ]
}

Returns metadata for the specified UUID, optionally including the custom data object for each.

To Get UUID Metadata you can use the following method(s) in the JavaScript V4 SDK:

  1. ParameterTypeRequiredDefaultsDescription
    uuidStringOptionalcurrent uuidUnique user identifier. If not supplied then current user’s uuid is used.
    includeObjectOptionalInclude respective additional fields in the response.
    customFieldsBooleanOptionaltrueWhether to fetch custom fields or not.
    callback(result) => voidOptionalCallback to the function. If not passed, the function will return a Promise instead.
// using UUID from the config
pubnub.objects.getUUIDMetadata(); 

// using passed in UUID
pubnub.objects.getUUIDMetadata({
    uuid: 'myUuid',
});
{
    "status": 200,
    "data": {
        "id": "uuid-1",
        "name": "John Doe",
        "externalId": null,
        "profileUrl": null,
        "email": "johndoe@pubnub.com",
        "updated": "2019-02-20T23:11:20.893755",
        "eTag": "MDcyQ0REOTUtNEVBOC00QkY2LTgwOUUtNDkwQzI4MjgzMTcwCg=="
    }
}

Set metadata for a UUID in the database, optionally including the custom data object for each.

To Set UUID Metadata you can use the following method(s) in the JavaScript V4 SDK:

  1. ParameterTypeRequiredDefaultsDescription
    uuidStringOptionalcurrent uuidUnique user identifier. If not supplied then current user’s uuid is used.
    dataObjectYesJSON object with uuid metadata to set.
    nameStringOptionalDisplay name for the user.
    Maximum 200 characters.
    externalIdStringOptionalUser's identifier in an external system
    profileUrlStringOptionalThe URL of the user's profile picture
    emailStringOptionalThe user's email address.
    Maximum 80 characters.
    customObjectOptionalJSON object of key-value pairs with supported data types.
    includeObjectOptionalInclude respective additional fields in the response.
    customFieldsBooleanOptionaltrueWhether to fetch custom fields or not.
    callback(result) => voidOptionalCallback to the function. If not passed, the function will return a Promise instead.
 // using UUID from the config
pubnub.objects.setUUIDMetadata({
    data: {
        name: 'John Doe'
    }
});

// using passed in UUID
pubnub.objects.setUUIDMetadata({
    uuid: 'myUuid',
    data: {}
});
{
    "status": 200,
    "data": {
        "id": "uuid-1",
        "name": "John Doe",
        "externalId": null,
        "profileUrl": null,
        "email": "johndoe@pubnub.com",
        "updated": "2019-02-20T23:11:20.893755",
        "eTag": "MDcyQ0REOTUtNEVBOC00QkY2LTgwOUUtNDkwQzI4MjgzMTcwCg=="
    }
}

Removes the metadata from a specified UUID.

To Remove UUID Metadata you can use the following method(s) in the JavaScript V4 SDK:

  1. ParameterTypeRequiredDefaultsDescription
    uuidStringOptionalcurrent uuidUnique user identifier. If not supplied then current user’s uuid is used.
    callback(result) => voidOptionalCallback to the function. If not passed, the function will return a Promise instead.
// using UUID from the config
pubnub.objects.removeUUIDMetadata();

// using passed in UUID
pubnub.objects.removeUUIDMetadata({
    uuid: 'myUuid'
});
{
    "status": 0,
    "data": {}
}

Returns a paginated list of Channel Metadata objects, optionally including the custom data object for each.

To Get All Channel Metadata you can use the following method(s) in the JavaScript V4 SDK:

  1. ParameterTypeRequiredDefaultsDescription
    includeObjectOptionalInclude respective additional fields in the response.
    totalCountBooleanOptionalfalseRequest totalCount to be included in paginated response. By default, totalCount is omitted.
    customFieldsBooleanOptionalfalseWhether to fetch custom fields or not.
    filterStringOptionalExpression used to filter the results. Only objects whose properties satisfy the given expression are returned. The filter language is defined here.
    sortObjectOptionalKey-value pair of a property to sort by, and a sort direction. Available options are id, name, and updated.

    Use asc or desc to specify sort direction, or specify null to take the default sort direction (ascending).

    For example: {name: 'asc'}
    limitNumberOptional100Number of objects to return in response. Default is 100, which is also the maximum value.
    pageObjectOptionalUse for pagination.
    nextStringOptionalPreviously-returned cursor bookmark for fetching the next page.
    prevStringOptionalPreviously-returned cursor bookmark for fetching the previous page. Ignored if you also supply the start parameter.
    callback(result) => voidOptionalCallback to the function. If not passed, the function will return a Promise instead.
pubnub.objects.getAllChannelMetadata({
    include: {
        totalCount: true
    }
});
{
    "status": 200,
    "data": [
        {
            "id": "my-channel",
            "name": "My channel",
            "description": "A channel that is mine",
            "custom": null,
            "updated": "2019-02-20T23:11:20.893755",
            "eTag": "RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg=="
        },
        {
            "id": "main",
            "name": "Main channel",
            "description": "The main channel",
            "custom": {
                "public": true,
                "motd": "Always check your spelling!"
            },
            "updated": "2019-02-20T23:11:20.893755",
            "eTag": "RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg=="
        }
    ],
    "totalCount": 9,
    "next": "MUIwQTAwMUItQkRBRC00NDkyLTgyMEMtODg2OUU1N0REMTNBCg==",
    "prev": "M0FFODRENzMtNjY2Qy00RUExLTk4QzktNkY1Q0I2MUJFNDRCCg=="
}

Returns metadata for the specified Channel, optionally including the custom data object for each.

To Get Channel Metadata you can use the following method(s) in the JavaScript V4 SDK:

  1. ParameterTypeRequiredDefaultsDescription
    channelStringYesChannel name.
    includeObjectOptionalInclude respective additional fields in the response.
    customFieldsBooleanOptionaltrueWhether to fetch custom fields or not.
    callback(result) => voidOptionalCallback to the function. If not passed, the function will return a Promise instead.
pubnub.objects.getChannelMetadata({
    channel: 'myChannel',
});
{
    "status": 200,
    "data": {
        "id": "my-channel",
        "name": "My channel",
        "description": "A channel that is mine",
        "updated": "2019-02-20T23:11:20.893755",
        "eTag": "RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg=="
    }
}

Set metadata for a Channel in the database, optionally including the custom data object for each.

To Set Channel Metadata you can use the following method(s) in the JavaScript V4 SDK:

  1. ParameterTypeRequiredDefaultsDescription
    channelStringYesChannel name.
    dataObjectYesJSON object with channel metadata to set.
    nameStringOptionalName of a channel.
    descriptionStringOptionalDescription of a channel.
    customObjectOptionalJSON object of key-value pairs with supported data types.
    includeObjectOptionalInclude respective additional fields in the response.
    customFieldsBooleanOptionaltrueWhether to fetch custom fields or not.
    callback(result) => voidOptionalCallback to the function. If not passed, the function will return a Promise instead.
pubnub.objects.setChannelMetadata({
    channel: 'myChannel',
    data: {
        name: 'Channel Name'
    }
});
{
    "status": 200,
    "data": {
        "id": "my-channel",
        "name": "My channel",
        "description": "A channel that is mine",
        "updated": "2019-02-20T23:11:20.893755",
        "eTag": "RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg=="
    }
}

Removes the metadata from a specified channel.

To Remove Channel Metadata you can use the following method(s) in the JavaScript V4 SDK:

  1. ParameterTypeRequiredDefaultsDescription
    channelStringYesChannel name.
    callback(result) => voidOptionalCallback to the function. If not passed, the function will return a Promise instead.
pubnub.objects.removeChannelMetadata({
    channel: 'myChannel'
});
{
    "status": 0,
    "data": {}
}

The method returns a list of channel memberships for a user. This method doesn't return a user's subscriptions.

To Get Memberships you can use the following method(s) in the JavaScript V4 SDK:

  1. ParameterTypeRequiredDefaultsDescription
    uuidStringOptionalcurrent uuidUnique user identifier. If not supplied then current user’s uuid is used.
    includeObjectOptionalInclude respective additional fields in the response.
    totalCountBooleanOptionalfalseRequest totalCount to be included in paginated response. By default, totalCount is omitted.
    customFieldsBooleanOptionalfalseWhether to fetch custom fields or not.
    channelFieldsBooleanOptionalfalseInclude fields for channels metadata.
    customChannelFieldsBooleanOptionalfalseInclude custom fields for channels metadata.
    filterStringOptionalExpression used to filter the results. Only objects whose properties satisfy the given expression are returned. The filter language is defined here.
    sortObjectOptionalKey-value pair of a property to sort by, and a sort direction. Available options are updated, channel.id, channel.name, and channel.updated.

    Use asc or desc to specify sort direction, or specify null to take the default sort direction (ascending).

    For example: {channel.name: 'asc'}
    limitNumberOptional100Number of objects to return in response. Default is 100, which is also the maximum value.
    pageObjectOptionalUse for pagination.
    nextStringOptionalPreviously-returned cursor bookmark for fetching the next page.
    prevStringOptionalPreviously-returned cursor bookmark for fetching the previous page. Ignored if you also supply the start parameter.
    callback(result) => voidOptionalCallback to the function. If not passed, the function will return a Promise instead.
// using UUID from the config
pubnub.objects.getMemberships();

// using passed in UUID
pubnub.objects.getMemberships({
    uuid: 'myUuid',
    include: {
        channelFields: true
    }
});
{
    "status": 200,
    "data": [
        {
            "channel": {
                "id": "my-channel",
                "name": "My channel",
                "description": "A channel that is mine",
                "custom": null,
                "updated": "2019-02-20T23:11:20.893755",
                "eTag": "RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg=="
            },
            "custom": {
                "starred": false
            },
            "updated": "2019-02-20T23:11:20.893755",
            "eTag": "RUNDMDUwNjktNUYwRC00RTI0LUI1M0QtNUUzNkE2NkU0MEVFCg=="
        },
        {
            "channel": {
                "id": "main",
                "name": "Main channel",
                "description": "The main channel",
                "custom": {
                    "public": true,
                    "motd": "Always check your spelling!"
                },
                "updated": "2019-02-20T23:11:20.893755",
                "eTag": "RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg=="
            },
            "updated": "2019-02-20T23:11:20.893755",
            "eTag": "RUNDMDUwNjktNUYwRC00RTI0LUI1M0QtNUUzNkE2NkU0MEVFCg=="
        }
    ],
    "totalCount": 7,
    "next": "RDIwQUIwM0MtNUM2Ni00ODQ5LUFGRjMtNDk1MzNDQzE3MUVCCg==",
    "prev": "MzY5RjkzQUQtNTM0NS00QjM0LUI0M0MtNjNBQUFGODQ5MTk2Cg=="
}

Set channel memberships for a UUID.

To Set Memberships you can use the following method(s) in the JavaScript V4 SDK:

  1. ParameterTypeRequiredDefaultsDescription
    uuidStringOptionalcurrent uuidUnique user identifier. If not supplied then current user’s uuid is used.
    channelsArrayYesArray of channels to add to membership. Array can contain strings (channel-name only) or objects (which can include custom data).
    includeObjectOptionalInclude respective additional fields in the response.
    totalCountBooleanOptionalfalseRequest totalCount to be included in paginated response. By default, totalCount is omitted.
    customObjectOptionalJSON object of key-value pairs with supported data types.
    customFieldsBooleanOptionalfalseWhether to fetch custom fields or not.
    channelFieldsBooleanOptionalfalseInclude fields for channels metadata.
    customChannelFieldsBooleanOptionalfalseInclude custom fields for channels metadata.
    filterStringOptionalExpression used to filter the results. Only objects whose properties satisfy the given expression are returned. The filter language is defined here.
    sortObjectOptionalKey-value pair of a property to sort by, and a sort direction. Available options are updated, channel.id, channel.name, and channel.updated.

    Use asc or desc to specify sort direction, or specify null to take the default sort direction (ascending).

    For example: {channel.name: 'asc'}
    limitNumberOptional100Number of objects to return in response. Default is 100, which is also the maximum value.
    pageObjectOptionalUse for pagination.
    nextStringOptionalPreviously-returned cursor bookmark for fetching the next page.
    prevStringOptionalPreviously-returned cursor bookmark for fetching the previous page. Ignored if you also supply the start parameter.
    callback(result) => voidOptionalCallback to the function. If not passed, the function will return a Promise instead.
// using UUID from the config
pubnub.objects.setMemberships({
    channels: ['ch-1', 'ch-2']
}); 

// using passed in UUID
pubnub.objects.setMemberships({
 uuid: 'my-uuid',
 channels: [
   "my-channel-1",
   { id: "my-channel-2" },
   { id: "my-channel-3", custom: { hello: "world" } },
   include: {
        // To include channel fields in response
        channelFields: true
    }
 ]
});
{
    "status": 200,
    "data": [
        {
            "channel": {
              "id": "my-channel",
              "name": "My channel",
              "description": "A channel that is mine",
              "custom": null,
              "updated": "2019-02-20T23:11:20.893755",
              "eTag": "RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg=="
            },
            "custom": {
                "starred": false
            },
            "updated": "2019-02-20T23:11:20.893755",
            "eTag": "RUNDMDUwNjktNUYwRC00RTI0LUI1M0QtNUUzNkE2NkU0MEVFCg=="
        },
        {
          "channel": {
              "id": "main",
              "name": "Main channel",
              "description": "The main channel",
              "custom": {
                  "public": true,
                  "motd": "Always check your spelling!"
              },
              "updated": "2019-02-20T23:11:20.893755",
              "eTag": "RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg=="
          },
          "updated": "2019-02-20T23:11:20.893755",
          "eTag": "RUNDMDUwNjktNUYwRC00RTI0LUI1M0QtNUUzNkE2NkU0MEVFCg=="
        }
    ],
    "totalCount": 7,
    "next": "RDIwQUIwM0MtNUM2Ni00ODQ5LUFGRjMtNDk1MzNDQzE3MUVCCg==",
    "prev": "MzY5RjkzQUQtNTM0NS00QjM0LUI0M0MtNjNBQUFGODQ5MTk2Cg=="
}

Remove channel memberships for a UUID.

To Remove Memberships you can use the following method(s) in the JavaScript V4 SDK:

  1. ParameterTypeRequiredDefaultsDescription
    uuidStringOptionalcurrent uuidUnique user identifier. If not supplied then current user’s uuid is used.
    channelsString[]YesChannels to remove from membership.
    includeObjectOptionalInclude respective additional fields in the response.
    totalCountBooleanOptionalfalseRequest totalCount to be included in paginated response. By default, totalCount is omitted.
    customFieldsBooleanOptionalfalseWhether to fetch custom fields or not.
    channelFieldsBooleanOptionalfalseInclude fields for channels metadata.
    customChannelFieldsBooleanOptionalfalseInclude custom fields for channels metadata.
    filterStringOptionalExpression used to filter the results. Only objects whose properties satisfy the given expression are returned. The filter language is defined here.
    sortObjectOptionalKey-value pair of a property to sort by, and a sort direction. Available options are updated, channel.id, channel.name, and channel.updated.

    Use asc or desc to specify sort direction., or specify null to take the default sort direction (ascending).

    For example: {channel.name: 'asc'}
    limitNumberOptional100Number of objects to return in response. Default is 100, which is also the maximum value.
    pageObjectOptionalUse for pagination.
    nextStringOptionalPreviously-returned cursor bookmark for fetching the next page.
    prevStringOptionalPreviously-returned cursor bookmark for fetching the previous page. Ignored if you also supply the start parameter.
    callback(result) => voidOptionalCallback to the function. If not passed, the function will return a Promise instead.
// using UUID from the config
pubnub.objects.removeMemberships({
    channels: ['ch-1', 'ch-2'],
}); 

// using passed in UUID
pubnub.objects.removeMemberships({
    uuid: 'myUuid',
    channels: ['ch-1', 'ch-2'],
});
{
    "status": 200,
    "data": [
        {
            "channel": {
              "id": "my-channel",
              "name": "My channel",
              "description": "A channel that is mine",
              "custom": null,
              "updated": "2019-02-20T23:11:20.893755",
              "eTag": "RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg=="
            },
            "custom": {
                "starred": false
            },
            "updated": "2019-02-20T23:11:20.893755",
            "eTag": "RUNDMDUwNjktNUYwRC00RTI0LUI1M0QtNUUzNkE2NkU0MEVFCg=="
        },
        {
            "channel": {
              "id": "main",
              "name": "Main channel",
              "description": "The main channel",
              "custom": {
                  "public": true,
                  "motd": "Always check your spelling!"
              },
              "updated": "2019-02-20T23:11:20.893755",
              "eTag": "RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg=="
            },
            "updated": "2019-02-20T23:11:20.893755",
            "eTag": "RUNDMDUwNjktNUYwRC00RTI0LUI1M0QtNUUzNkE2NkU0MEVFCg=="
        }
    ],
    "totalCount": 7,
    "next": "RDIwQUIwM0MtNUM2Ni00ODQ5LUFGRjMtNDk1MzNDQzE3MUVCCg==",
    "prev": "MzY5RjkzQUQtNTM0NS00QjM0LUI0M0MtNjNBQUFGODQ5MTk2Cg=="
}

The method returns a list of members in a channel. The list will include user metadata for members that have additional metadata stored in the database.

To Get Channel Members you can use the following method(s) in the JavaScript V4 SDK:

  1. ParameterTypeRequiredDefaultsDescription
    channelStringYesChannel name.
    includeObjectOptionalInclude respective additional fields in the response.
    totalCountBooleanOptionalfalseRequest totalCount to be included in paginated response. By default, totalCount is omitted.
    customFieldsBooleanOptionalfalseWhether to fetch custom fields or not.
    UUIDFieldsBooleanOptionalfalseInclude fields for UUIDs metadata.
    customUUIDFieldsBooleanOptionalfalseInclude custom fields for UUIDs metadata.
    filterStringOptionalExpression used to filter the results. Only objects whose properties satisfy the given expression are returned. The filter language is defined here.
    sortObjectOptionalKey-value pair of a property to sort by, and a sort direction. Available options are updated, uuid.id, uuid.name, and uuid.updated.

    Use asc or desc to specify sort direction, or specify null to take the default sort direction (ascending).

    For example: {uuid.name: 'asc'}
    limitNumberOptional100Number of objects to return in response. Default is 100, which is also the maximum value.
    pageObjectOptionalUse for pagination.
    nextStringOptionalPreviously-returned cursor bookmark for fetching the next page.
    prevStringOptionalPreviously-returned cursor bookmark for fetching the previous page. Ignored if you also supply the start parameter.
    callback(result) => voidOptionalCallback to the function. If not passed, the function will return a Promise instead.
pubnub.objects.getChannelMembers({
    channel: 'myChannel',
    include: {
        UUIDFields: true
    }
});
{
  "status": 200,
  "data": [
    {
      "uuid": {
        "id": "uuid-1",
        "name": "John Doe",
        "externalId": null,
        "profileUrl": null,
        "email": "jack@twitter.com",
        "custom": null,
        "updated": "2019-02-20T23:11:20.893755",
        "eTag": "MDcyQ0REOTUtNEVBOC00QkY2LTgwOUUtNDkwQzI4MjgzMTcwCg=="
      },
      "custom": {
        "role": "admin"
      },
      "updated": "2019-02-20T23:11:20.893755",
      "eTag": "QkRENDA5MjItMUZCNC00REI5LUE4QTktRjJGNUMxNTc2MzE3Cg=="
    },
    {
      "uuid": {
        "id": "uuid-2",
        "name": "Bob Cat",
        "externalId": null,
        "profileUrl": null,
        "email": "bobc@example.com",
        "custom": {
          "phone": "999-999-9999"
        },
        "updated": "2019-02-21T03:29:00.173452",
        "eTag": "QkRENDA5MjItMUZCNC00REI5LUE4QTktRjJGNUMxNTc2MzE3Cg=="
      },
      "updated": "2019-02-20T23:11:20.893755",
      "eTag": "QkRENDA5MjItMUZCNC00REI5LUE4QTktRjJGNUMxNTc2MzE3Cg=="
    }
  ],
  "totalCount": 37,
  "next": "RDIwQUIwM0MtNUM2Ni00ODQ5LUFGRjMtNDk1MzNDQzE3MUVCCg==",
  "prev": "MzY5RjkzQUQtNTM0NS00QjM0LUI0M0MtNjNBQUFGODQ5MTk2Cg=="
}

This method sets members in a channel.

To Set Channel Members you can use the following method(s) in the JavaScript V4 SDK:

  1. ParameterTypeRequiredDefaultsDescription
    channelStringYesChannel name.
    uuidsArrayYesArray of members to add to the channel. Array can contain strings (uuid only) or objects (which can include custom data).
    includeObjectOptionalInclude respective additional fields in the response.
    totalCountBooleanOptionalfalseRequest totalCount to be included in paginated response. By default, totalCount is omitted.
    customFieldsBooleanOptionalfalseWhether to fetch custom fields or not.
    UUIDFieldsBooleanOptionalfalseInclude fields for UUIDs metadata.
    customObjectOptionalJSON object of key-value pairs with supported data types.
    customUUIDFieldsBooleanOptionalfalseInclude custom fields for UUIDs metadata.
    filterStringOptionalExpression used to filter the results. Only objects whose properties satisfy the given expression are returned. The filter language is defined here.
    sortObjectOptionalKey-value pair of a property to sort by, and a sort direction. Available options are updated, uuid.id, uuid.name, and uuid.updated.

    Use asc or desc to specify sort direction, or specify null to take the default sort direction (ascending).

    For example: {uuid.name: 'asc'}
    limitNumberOptional100Number of objects to return in response. Default is 100, which is also the maximum value.
    pageObjectOptionalUse for pagination.
    nextStringOptionalPreviously-returned cursor bookmark for fetching the next page.
    prevStringOptionalPreviously-returned cursor bookmark for fetching the previous page. Ignored if you also supply the start parameter.
    callback(result) => voidOptionalCallback to the function. If not passed, the function will return a Promise instead.
pubnub.objects.setChannelMembers({
    channel: 'myChannel',
    uuids: ['uuid-1', 'uuid-2'],
});
{
    "status": 200,
    "data": [
        {
            "uuid": {
                "id": "uuid-1",
                "name": "John Doe",
                "externalId": null,
                "profileUrl": null,
                "email": "johndoe@pubnub.com",
                "custom": null,
                "updated": "2019-02-20T23:11:20.893755",
                "eTag": "MDcyQ0REOTUtNEVBOC00QkY2LTgwOUUtNDkwQzI4MjgzMTcwCg=="
            },
            "custom": {
                "role": "admin"
            },
            "updated": "2019-02-20T23:11:20.893755",
            "eTag": "QkRENDA5MjItMUZCNC00REI5LUE4QTktRjJGNUMxNTc2MzE3Cg=="
        },
        {
            "uuid": {
                "id": "uuid-2",
                "name": "Bob Cat",
                "externalId": null,
                "profileUrl": null,
                "email": "bobc@example.com",
                "custom": {
                    "phone": "999-999-9999"
                },
                "updated": "2019-02-21T03:29:00.173452",
                "eTag": "QkRENDA5MjItMUZCNC00REI5LUE4QTktRjJGNUMxNTc2MzE3Cg=="
            },
            "updated": "2019-02-20T23:11:20.893755",
            "eTag": "QkRENDA5MjItMUZCNC00REI5LUE4QTktRjJGNUMxNTc2MzE3Cg=="
        }
    ],
    "totalCount": 37,
    "next": "RDIwQUIwM0MtNUM2Ni00ODQ5LUFGRjMtNDk1MzNDQzE3MUVCCg==",
    "prev": "MzY5RjkzQUQtNTM0NS00QjM0LUI0M0MtNjNBQUFGODQ5MTk2Cg=="
}

Remove members from a Channel.

To Remove Channel Members you can use the following method(s) in the JavaScript V4 SDK:

  1. ParameterTypeRequiredDefaultsDescription
    channelStringYesChannel name.
    uuidsString[]YesMembers to remove from channel.
    includeObjectOptionalInclude respective additional fields in the response.
    totalCountBooleanOptionalfalseRequest totalCount to be included in paginated response. By default, totalCount is omitted.
    customFieldsBooleanOptionalfalseWhether to fetch custom fields or not.
    UUIDFieldsBooleanOptionalfalseInclude fields for UUIDs metadata.
    customUUIDFieldsBooleanOptionalfalseInclude custom fields for UUIDs metadata.
    filterStringOptionalExpression used to filter the results. Only objects whose properties satisfy the given expression are returned. The filter language is defined here.
    sortObjectOptionalKey-value pair of a property to sort by, and a sort direction. Available options are updated, uuid.id, uuid.name, and uuid.updated.

    Use asc or desc to specify sort direction, or specify null to take the default sort direction (ascending).

    For example: {uuid.name: 'asc'}
    limitNumberOptional100Number of objects to return in response. Default is 100, which is also the maximum value.
    pageObjectOptionalUse for pagination.
    nextStringOptionalPreviously-returned cursor bookmark for fetching the next page.
    prevStringOptionalPreviously-returned cursor bookmark for fetching the previous page. Ignored if you also supply the start parameter.
    callback(result) => voidOptionalCallback to the function. If not passed, the function will return a Promise instead.
pubnub.objects.removeChannelMembers({
    channel: 'myChannel',
    uuids: ['uuid-1', 'uuid-2'],
});
{
    "status": 200,
    "data": [
        {
            "uuid": {
                "id": "uuid-1",
                "name": "John Doe",
                "externalId": null,
                "profileUrl": null,
                "email": "johndoe@pubnub.com",
                "custom": null,
                "updated": "2019-02-20T23:11:20.893755",
                "eTag": "MDcyQ0REOTUtNEVBOC00QkY2LTgwOUUtNDkwQzI4MjgzMTcwCg=="
            },
            "custom": {
                "role": "admin"
            },
            "updated": "2019-02-20T23:11:20.893755",
            "eTag": "QkRENDA5MjItMUZCNC00REI5LUE4QTktRjJGNUMxNTc2MzE3Cg=="
        },
        {
            "uuid": {
                "id": "uuid-2",
                "name": "Bob Cat",
                "externalId": null,
                "profileUrl": null,
                "email": "bobc@example.com",
                "custom": {
                    "phone": "999-999-9999"
                },
                "updated": "2019-02-21T03:29:00.173452",
                "eTag": "QkRENDA5MjItMUZCNC00REI5LUE4QTktRjJGNUMxNTc2MzE3Cg=="
            },
            "updated": "2019-02-20T23:11:20.893755",
            "eTag": "QkRENDA5MjItMUZCNC00REI5LUE4QTktRjJGNUMxNTc2MzE3Cg=="
        }
    ],
    "totalCount": 37,
    "next": "RDIwQUIwM0MtNUM2Ni00ODQ5LUFGRjMtNDk1MzNDQzE3MUVCCg==",
    "prev": "MzY5RjkzQUQtNTM0NS00QjM0LUI0M0MtNjNBQUFGODQ5MTk2Cg=="
}

The filtering language for Objects is similar to the stream filtering language.

Note the following:

  • Date/time properties, such as updated, must be compared to valid date/time strings formatted according to ISO 8601.
  • Custom properties must have the same type as the value used in the expression; it is an error to compare a custom property of one type to a value of another type.
  • Objects that do not have the referenced custom property at all are excluded regardless of the operator or value used in the expression. The null value can be used to filter out objects that do or do not have the referenced custom property.
  • The LIKE operator supports wildcards denoted by the * character. A wildcard matches any sequence of arbitrary Unicode characters, including the empty sequence. The literal asterisk is matched when escaped using the backslash (\) character.
  • Values used with LIKE must be properly encoded just like any other string value. Thus, in order to escape an asterisk, the raw value must contain \\*.
  • The entire expression must be properly URL-encoded when used in the query string.

<expression>           ::= <and_expression> ( "||" <and_expression> )*
<and_expression>       ::= <binary_condition> ( "&&" <binary_condition> )*
<binary_condition>     ::= "!" <binary_condition> | "(" <expression> ")" | <relational_condition>
<relational_condition> ::= <property_path> <relational_operator> <value>
<property_path>        ::= <property_name> ( "." <property_name> )*
<property_name>        ::= <identifier> | "[" <string> "]"
<value>                ::= <string> | <number> | "true" | "false" | "null"

Tokens

<identifier>           ::=  <letter> | "$" | "_" ( <letter> | "$" | "_" | <digit> )*
<relational_operator>  ::= "==" | "!=" | "<=" | ">=" | "<" | ">" | "LIKE"
<string>               ::= <double_quote> ( "\" <double_quote> | "\" <special_char>
                            | "\" "u" <hex_digit> <hex_digit> <hex_digit> <hex_digit>
                            | <unicode_char> - <double_quote> - "\" )* <double_quote>
                            | "'" ( "\" "'" | "\" <special_char>
                            | "\" "u" <hex_digit> <hex_digit> <hex_digit> <hex_digit>
                            | <unicode_char> - "'" - "\" )* "'"
<number>               ::= ( "+" | "-" )? ( <digit> )* ( "." )? <digit> ( <digit> )* 
                            ( "e" | "E" ( "+" | "-" )? <digit> ( <digit> )* )?
<letter>               ::= Unicode Letter (category; any kind of letter from any language)
<digit>                ::= "0" .. "9"
<hex_digit>            ::= <digit> | "A" .. "F"
<double_quote>         ::= the " character
<unicode_char>         ::= any character in the Unicode range from U+0020 to U+10FFFF inclusive
<special_char>         ::= "\" | "/" | "b" | "f" | "n" | "r" | "t"

The following simple expression returns results whose custom property named public is equal to Boolean true.


custom.public == true

The following date/time comparison returns results that were modified on or after August 31st, 2019 (UTC):


updated >= "2019-08-31T00:00:00Z"

The following compound expression returns results that don't have a description, but do have a non-empty custom label or description property:


description == null && (custom.label != "" || custom.description != "")

The following wildcard expression returns results whose name starts with the letter X:


name LIKE 'X*'

The following escaped wildcard expression returns results whose name contains an asterisk:


name LIKE '*\\**'