App Context Filtering Language
PubNub SDKs, REST API, and BizOps Workspace allow you to specify conditions for querying and interacting with user, channel, and membership data (collectively called App Context) using a combination of operators and functions.
You can use the filter
parameter to query data fields for users, channels, and memberships and get or change that data based on certain conditions.
Read on to learn which App Context data you can filter through and which operators and expressions you can use for this purpose.
This document shows examples of handling data in your applications using different SDK methods. Still, you can refer to the REST API documentation to learn how to directly query PubNub's server data or read BizOps Workspace docs to find out how to filter user and channel data through UI.
Data fields
Here is a list of data fields available for querying and managing users, channels, and channel memberships using PubNub’s App Context Filtering Language.
User data fields
Data fields format
Format of these parameters can vary between REST API, SDKs, and BizOps Workspace.
id
— Unique user identifier (UUID)name
— User's display nameexternalId
— An identifier that links the user to an external systemprofileUrl
— URL to the user's profile pictureemail
— User's email addressstatus
— Condition the user is in, likeactive
(some SDKs)type
— Category used to classify the user, likeSupportAgent
(some SDKs)updated
— Timestamp of the last update to the user's metadatacustom
— Any user-specific property (filtering through it is not recommended in SDKs and BizOps Workspace)
Channel data fields
id
— Unique channel identifiername
— Display name of the channeldescription
— Description of the channelstatus
— Condition the channel is in, likearchived
(some SDKs)type
— Category used to classify the channel, likeOffTopic
(some SDKs)updated
— Timestamp of the last update to the channel's metadatacustom
— Any channel-specific property (filtering through it is not recommended in SDKs and BizOps Workspace)
Channel memberships and members data fields
channel.id
- Identifier of the channel associated with the membershipchannel.name
— Name of the channelchannel.description
— Channel descriptionchannel.status
— Condition the channel is in, likearchived
(some SDKs)channel.type
— Category used to classify the channel, likeOffTopic
(some SDKs)channel.updated
— Timestamp of the last update to the channel's metadatachannel.custom
- Any channel-specific property (filtering through it is not recommended in SDKs and BizOps Workspace)uuid.id
— The UUID of the channel memberuuid.name
— Name of the channel memberuuid.externalId
— An identifier that links the channel member to an external systemuuid.profileUrl
— URL to the channel member's profile pictureuuid.email
— Channel member's email addressuuid.status
— Condition the channel member is in, likeactive
(some SDKs)uuid.type
— Category used to classify the channel member, likeSupportAgent
(some SDKs)uuid.updated
— Timestamp when the channel member was last updateduuid.custom
- Any channel member-specific property (filtering through it is not recommended in SDKs and BizOps Workspace)status
— Condition the membership is intype
— Category used to classify the membership, likesubscription
(only REST API)custom
— Any membership-specific property (filtering through it is not recommended)
Filtering operators
When retrieving metadata for users or channels, pass a filter
parameter, which contains an expression that determines which records to return based on the properties of those records. The filtering language supports basic operators like comparison (==
, !=
, >
, <
, >=
, <=
), logical operators (&&
, ||
), and the ability to check for presence or patterns using LIKE
.
==
(equal to)!=
(not equal to)<
(less than)>
(greater than)<=
(less than or equal to)>=
(greater than or equal to)&&
(and)||
(or)LIKE
(SQL-like pattern matching, supports*
as wildcard for string fields)
Query parameters and methods
You can filter App Context data in one of the following ways:
-
Using the REST API calls to get the data:
-
Using SDK methods that accept the
filter
parameter to limit App Context data when getting, setting, or removing it, likegetAllUUIDMetadata()
,getAllChannelMetadata()
,getMemberships()
, orsetChannelMembers()
in the JavaScript SDK.For details, head to the
App Context
document in a selected SDK documentation set.Filtering through custom properties
To avoid performance issues, do not filter App Context data through the
custom
fields using SDK methods. -
UI filters in BizOps Workspace:
Filtering through custom properties
To avoid performance issues, do not filter App Context data through the
custom
fields using BizOps Workspace.
Filter expression components
The filter expression syntax in PubNub's App Context API can be structured into categories that include expressions for logical operations, data referencing tools, literals representing fixed values, and tokens that assist in constructing queries, enabling complex condition formulation and data manipulation in queries.
Expressions and conditions
This category contains the elements that form the logical structure of queries, allowing the definition of conditions and decision-making expressions based on data.
Element | Description | Syntax/Example |
---|---|---|
Expression | Main building block, evaluates to true or false based on conditions | email LIKE "*@example.com" |
And expression | Combines conditions that must all be true (logical AND) | name == "Alice" && email LIKE "*@example.com" |
Binary condition | Basic unit for simple or negated conditions | !(name == "Alice") |
Relational condition | Compares properties to values | profileUrl != "http://example.com/default.jpg" |
Data references and operators
This category includes the tools for referencing data properties and manipulating them through various operators.
Element | Description | Syntax/Example |
---|---|---|
Identifier | Must start with a letter (A-Z, a-z), $ , or _ , and allow subsequent characters to include letters, digits (0-9), $ , or _ . | my_user_id , $userID , _user_912710938aa848eda2c3e0c2b583 |
Property name | Can be an alternative form of an identifier represented by a string enclosed in square brackets. Using square brackets makes most sense for non-regular (custom ) fields containing special characters or spaces that are not supported directly with identifiers, but filtering through custom fields is not recommended for SDKs and BizOps Workspace. | ["name"] == "John" (same as identifier name , but in brackets) or custom["employment-status"] == "valid" (as custom.employment-status == "test" would throw an error due to invalid - character) |
Property path | Accesses nested properties using dot notation | channel.name == "general" |
Relational operator | Operators to compare properties and values | == , != , < , > , <= , >= , LIKE |
Literals and data types
Elements in this category represent specific data values or constants used within filter expressions.
Element | Description | Syntax/Example |
---|---|---|
Value | Fixed data values like strings, numbers, booleans, or null | status == "active" |
String | Text values, enclosed in quotes (supports escaped characters) | "Hello \"World\"" |
Characters and tokens
Key single characters and symbols used to construct literals, strings, and structure within the syntax.
Element | Description | Syntax/Example |
---|---|---|
Letter | Any alphabetic character from any language | a , Z , é , λ |
Number | Numeric values, supports integers, decimals, and scientific notation | 3.14159 , -42 , 6.022e23 |
Digit | Numbers from 0 to 9 | 0 , 9 |
Hex digit | Hexadecimal digit used in unicode encoding | 0 , 9 , A , F |
Double quote | Used to denote the start and end of strings | "This is a string" |
Unicode character | Any character valid in the Unicode range | Any visible character, emoji, etc. |
Special character | Characters that perform special functions in strings. For example, if you want to search for parameters that contain an asterisk, you must escape this special character, like filter: 'name LIKE '*\\**' . | \n (new line), \t (tab), \\ (backslash) |
Examples
Expression
Get all users whose names start with John
.
- JavaScript
- Swift
- Kotlin
- Python
pubnub.objects.getAllUUIDMetadata({
filter: 'name LIKE "John*"'
})
pubnub.allUUIDMetadata(
filter: "name LIKE 'John*'",
completion: { result in
switch result {
case .success(let response):
let uuids = response.uuids
print("Fetched UUID Metadata: \(uuids)")
case .failure(let error):
print("Failed to fetch UUID Metadata: \(error.localizedDescription)")
}
}
)
pubnub.getAllUUIDMetadata(
filter = "name LIKE 'John*'"
).async { result: Result<PNUUIDMetadataArrayResult> ->
result.onFailure { exception ->
println("Error fetching UUID metadata: ${exception.message}")
}.onSuccess { value: PNUUIDMetadataArrayResult ->
value.data.forEach { metadata ->
println("UUID: ${metadata.id}, Name: ${metadata.name}")
}
}
}
def callback(response, status):
if status.is_error():
print(f"Error fetching UUID metadata: {status.error_message}")
else:
for uuid_data in response.data:
print(f"UUID: {uuid_data['id']}, Name: {uuid_data['name']}")
pubnub.get_all_uuid_metadata()
.filter("name LIKE 'John*'")
.pn_async(callback)
And expression
Get metadata of channels that include general
in names and were updated after January 1st, 2023.
- JavaScript
- Swift
- Kotlin
- Python
pubnub.objects.getAllChannelMetadata({
filter: 'name LIKE "*general*" && updated >= "2023-01-01T00:00:00Z"'
})
pubnub.allChannelMetadata(
filter: "name LIKE '*general*' && updated >= '2023-01-01T00:00:00Z'",
completion: { result in
switch result {
case .success(let data):
let channels = data.channels
print("Filtered Channels: \(channels)")
case .failure(let error):
print("Error fetching channel metadata: \(error.localizedDescription)")
}
}
)
pubnub.getAllChannelMetadata(
filter = "name LIKE '*general*' && updated >= '2023-01-01T00:00:00Z'"
).async { result: Result<PNChannelMetadataArrayResult> ->
result.onFailure { exception ->
println("Error fetching channel metadata: ${exception.message}")
}.onSuccess { value: PNChannelMetadataArrayResult ->
value.data.forEach { channel ->
println("Channel ID: ${channel.id}, Name: ${channel.name}")
}
}
}
def callback(response, status):
if status.is_error():
print(f"Error fetching channel metadata: {status.error_message}")
else:
for channel in response.data:
print(f"Channel ID: {channel['id']}, Name: {channel['name']}, Updated: {channel['updated']}")
pubnub.get_all_channel_metadata() \
.filter("name LIKE '*general*' && updated >= '2023-01-01T00:00:00Z'") \
.pn_async(callback)
Binary condition
Retrieve all user memberships excluding the channel with ID Channel-001
.
- JavaScript
- Swift
- Kotlin
- Python
pubnub.objects.getMemberships({
uuid: 'user123',
filter: '!(channel.id == "Channel-001")'
})
pubnub.fetchMemberships(
uuid: "user123",
filter: "!(channel.id == 'Channel-001')",
completion: { result in
switch result {
case .success(let data):
let memberships = data.memberships
print("Filtered Memberships: \(memberships)")
case .failure(let error):
print("Error fetching memberships: \(error.localizedDescription)")
}
}
)
val userId = "user123"
pubnub.getMemberships(
uuid = userId,
filter = "!(channel.id == 'Channel-001')"
).async { result ->
result.onFailure { exception ->
println("Error fetching memberships: ${exception.message}")
}.onSuccess{ value ->
println("Successfully removed channel members")
value.data.forEach { membership ->
println("Channel ID: ${membership.channel?.id}, User ID: $userId")
}
}
}
memberships = pubnub.get_memberships() \
.uuid("user123") \
.filter("!(channel.id == 'Channel-001')") \
.sync()
if memberships.status.is_error():
print(f"Error fetching memberships: {memberships.status}")
else:
print(memberships.__dict__)
for membership in memberships.result.data:
print(f"Channel ID: {membership['channel']['id']}")
Relational condition
Find channel members whose last update was before a specific time.
- JavaScript
- Swift
- Kotlin
- Python
pubnub.objects.getChannelMembers({
channel: "specialEvents",
filter: 'uuid.updated < "2023-01-01T00:00:00Z"'
})
pubnub.fetchMembers(
channel: "specialEvents",
filter: "uuid.updated < '2023-01-01T00:00:00Z'",
completion: { result in
switch result {
case .success(let response):
let memberships = response.memberships
print("Fetched Memberships: \(memberships)")
case .failure(let error):
print("Failed to fetch Memberships: \(error.localizedDescription)")
}
}
)
val channel = "specialEvents"
pubnub.getChannelMembers(
channel = channel,
filter = "uuid.updated < '2023-01-01T00:00:00Z'"
).async { result ->
result.onFailure { exception: PubNubException ->
println("Error fetching channel members: ${exception.message}")
}.onSuccess { value: PNMemberArrayResult ->
value.data.forEach { member ->
println("Member UUID: ${member.uuid}, Channel: $channel")
}
}
}
def callback(response, status):
if status.is_error():
print(f"Error fetching channel members: {status.error_message}")
else:
for member in response.data:
print(f"Member UUID: {member['uuid']}, Channel: {member['channel']}")
pubnub.get_channel_members() \
.channel("specialEvents") \
.filter("uuid.updated < '2023-01-01T00:00:00Z'") \
.pn_async(callback)
Identifier
Retrieve all users whose name is John
.
- JavaScript
- Swift
- Kotlin
- Python
pubnub.objects.getAllUUIDMetadata({
filter: 'name == "John"'
})
pubnub.allUUIDMetadata(
filter: "name == 'John'",
completion: { result in
switch result {
case .success(let response):
let uuids = response.uuids
print("Fetched UUID Metadata: \(uuids)")
case .failure(let error):
print("Failed to fetch UUID Metadata: \(error.localizedDescription)")
}
}
)
pubnub.getAllUUIDMetadata(
filter = "name == 'John'"
).async { result ->
result.onFailure { exception ->
println("Error fetching UUID metadata: ${exception.message}")
}.onSuccess { value ->
value.data.forEach { metadata ->
println("UUID: ${metadata.id}, Name: ${metadata.name}")
}
}
}
def callback(response, status):
if status.is_error():
print(f"Error fetching UUID metadata: {status.error_message}")
else:
for uuid_data in response.data:
print(f"UUID: {uuid_data['id']}, Name: {uuid_data['name']}")
pubnub.get_all_uuid_metadata()
.filter("name == 'John'")
.pn_async(callback)
Property name
Retrieve all channels whose descriptions contain support
.
- JavaScript
- Swift
- Kotlin
- Python
pubnub.objects.getAllChannelMetadata({
filter: '["description"] LIKE "*support*"'
})
pubnub.allChannelMetadata(
filter: "['description'] LIKE '*support*'",
completion: { result in
switch result {
case .success(let data):
let channels = data.channels
print("Filtered Channels: \(channels)")
case .failure(let error):
print("Error fetching channel metadata: \(error.localizedDescription)")
}
}
)
pubnub.getAllChannelMetadata(
filter = "description LIKE '*support*'"
).async { result ->
result.onFailure { exception ->
println("Error fetching channel metadata: ${exception.message}")
}.onSuccess { value ->
value.data.forEach { channel ->
println("Channel ID: ${channel.id}, Name: ${channel.name}")
}
}
}
def callback(response, status):
if status.is_error():
print(f"Error fetching channel metadata: {status.error_message}")
else:
for channel in response.data:
print(f"Channel ID: {channel['id']}, Name: {channel['name']}, Updated: {channel['updated']}")
pubnub.get_all_channel_metadata() \
.filter("['description'] LIKE '*support*'") \
.pn_async(callback)
Property path
Retrieve all user memberships where channel ID starts with user
.
- JavaScript
- Swift
- Kotlin
- Python
pubnub.objects.getMemberships({
uuid: 'user123',
filter: 'channel.id LIKE "user*")'
})
pubnub.fetchMemberships(
uuid: "user123",
filter: "(channel.id LIKE 'user*')",
completion: { result in
switch result {
case .success(let data):
let memberships = data.memberships
print("Filtered Memberships: \(memberships)")
case .failure(let error):
print("Error fetching memberships: \(error.localizedDescription)")
}
}
)
val userId = "user123"
pubnub.getMemberships(
uuid = userId,
filter = "!(channel.id LIKE 'user*')"
).async { result ->
result.onFailure { exception ->
println("Error fetching memberships: ${exception.message}")
}.onSuccess{ value ->
println("Successfully removed channel members")
value.data.forEach { membership ->
println("Channel ID: ${membership.channel?.id}, User ID: $userId")
}
}
}
def callback(response, status):
if status.is_error():
print(f"Error fetching memberships: {status.error_message}")
else:
for membership in response.data:
print(f"Membership ID: {membership['id']}, Channel ID: {membership['channel']['id']}, User ID: {membership['uuid']}")
pubnub.get_memberships() \
.uuid("user123") \
.filter("(channel.id LIKE 'user*')") \
.pn_async(callback)
Relational operator
Add to the advancedChannel
channel all specified users, but return only those users whose IDs are greater than a certain value (250
).
- JavaScript
- Swift
- Kotlin
- Python
pubnub.objects.setChannelMembers({
channel: "advancedChannel",
uuids: [
{ id: "201" },
{ id: "300" },
{ id: "450" },
{ id: "789" }
],
filter: 'uuid.id > "250"'
});
pubnub.setMembers(
channel: "advancedChannel",
uuids: [
PubNubMembershipMetadataBase(uuidMetadataId: "201", channelMetadataId: "advancedChannel"),
PubNubMembershipMetadataBase(uuidMetadataId: "300", channelMetadataId: "advancedChannel"),
PubNubMembershipMetadataBase(uuidMetadataId: "450", channelMetadataId: "advancedChannel"),
PubNubMembershipMetadataBase(uuidMetadataId: "789", channelMetadataId: "advancedChannel")
],
filter: "uuid.id > '250'",
completion: { result in
switch result {
case .success(let data):
let memberships = data.memberships
print("Updated Memberships: \(memberships)")
case .failure(let error):
show all 19 linesval channel = "advancedChannel"
pubnub.setChannelMembers(
uuids = listOf(
PNMember.Partial(uuidId = "201"),
PNMember.Partial(uuidId = "300"),
PNMember.Partial(uuidId = "450"),
PNMember.Partial(uuidId = "789")
),
channel = channel,
filter = "uuid.id > '250'"
).async { result ->
result.onFailure { exception ->
println("Error setting channel members: ${exception.message}")
}.onSuccess{ value ->
value.data.forEach { member ->
show all 19 linesdef callback(response, status):
if status.is_error():
print(f"Error setting channel members: {status.error_message}")
else:
for member in response.data:
print(f"Member UUID: {member['uuid']}, Channel: {member['channel']}")
pubnub.set_channel_members() \
.channel("advancedChannel") \
.uuids([
PNUUID(uuid="201"),
PNUUID(uuid="300"),
PNUUID(uuid="450"),
PNUUID(uuid="789")
]) \
show all 17 linesValue
Get all oldChannel
channel members with the inactive
status.
- JavaScript
- Swift
- Kotlin
- Python
pubnub.objects.getChannelMembers({
channel: "oldChannel",
filter: 'uuid.status == "inactive"'
})
pubnub.fetchMembers(
channel: "oldChannel",
filter: "uuid.status == 'inactive'",
completion: { result in
switch result {
case .success(let response):
let memberships = response.memberships
print("Fetched Memberships: \(memberships)")
case .failure(let error):
print("Failed to fetch Memberships: \(error.localizedDescription)")
}
}
)
val channel = "oldChannel"
pubnub.getChannelMembers(
channel = channel,
filter = "uuid.status == 'inactive'"
).async { result ->
result.onFailure { exception: PubNubException ->
println("Error fetching channel members: ${exception.message}")
}.onSuccess { value: PNMemberArrayResult ->
value.data.forEach { member ->
println("Member UUID: ${member.uuid}, Channel: $channel")
}
}
}
def callback(response, status):
if status.is_error():
print(f"Error fetching channel members: {status.error_message}")
else:
for member in response.data:
print(f"Member UUID: {member['uuid']}, Channel: {member['channel']}")
pubnub.get_channel_members() \
.channel("oldChannel") \
.filter("uuid.status == 'inactive'") \
.pn_async(callback)
String
Get metadata of a channel with a description including escaped characters.
- JavaScript
- Swift
- Kotlin
- Python
pubnub.objects.getAllChannelMetadata({
filter: 'description == "Hello \\"Gossipers\\""'
})
pubnub.allChannelMetadata(
filter: "description == 'Hello \\'Gossipers\\''",
completion: { result in
switch result {
case .success(let data):
let channels = data.channels
print("Filtered Channels: \(channels)")
case .failure(let error):
print("Error fetching channel metadata: \(error.localizedDescription)")
}
}
)
pubnub.getAllChannelMetadata(
filter = "description == 'Hello \\'Gossipers\\''"
).async { result ->
result.onFailure { exception ->
println("Error fetching channel metadata: ${exception.message}")
}.onSuccess { value ->
value.data.forEach { channel ->
println("Channel ID: ${channel.id}, Name: ${channel.name}")
}
}
}
def callback(response, status):
if status.is_error():
print(f"Error fetching channel metadata: {status.error_message}")
else:
for channel in response.data:
print(f"Channel ID: {channel['id']}, Name: {channel['name']}, Updated: {channel['updated']}")
pubnub.get_all_channel_metadata() \
.filter("description == 'Hello \\'Gossipers\\''") \
.pn_async(callback)
Letter
Get all users whose names start with J
.
- JavaScript
- Swift
- Kotlin
- Python
pubnub.objects.getAllUUIDMetadata({
filter: 'name LIKE "J*"'
})
pubnub.allUUIDMetadata(
filter: "name LIKE 'J*'",
completion: { result in
switch result {
case .success(let response):
let uuids = response.uuids
print("Fetched UUID Metadata: \(uuids)")
case .failure(let error):
print("Failed to fetch UUID Metadata: \(error.localizedDescription)")
}
}
)
pubnub.getAllUUIDMetadata(
filter = "name LIKE 'J*'"
).async { result ->
result.onFailure { exception ->
println("Error fetching UUID metadata: ${exception.message}")
}.onSuccess { value ->
value.data.forEach { metadata ->
println("UUID: ${metadata.id}, Name: ${metadata.name}")
}
}
}
def callback(response, status):
if status.is_error():
print(f"Error fetching UUID metadata: {status.error_message}")
else:
for uuid_data in response.data:
print(f"UUID: {uuid_data['id']}, Name: {uuid_data['name']}")
pubnub.get_all_uuid_metadata()
.filter("name LIKE 'J*'")
.pn_async(callback)
Number
Get metadata of channels that were updated after January 1st, 2023.
- JavaScript
- Swift
- Kotlin
- Python
pubnub.objects.getAllChannelMetadata({
filter: 'updated >= "2023-01-01T00:00:00Z"'
})
pubnub.allChannelMetadata(
filter: "updated >= '2023-01-01T00:00:00Z'",
completion: { result in
switch result {
case .success(let data):
let channels = data.channels
print("Filtered Channels: \(channels)")
case .failure(let error):
print("Error fetching channel metadata: \(error.localizedDescription)")
}
}
)
pubnub.getAllChannelMetadata(
filter = "updated >= '2023-01-01T00:00:00Z'"
).async { result ->
result.onFailure { exception ->
println("Error fetching channel metadata: ${exception.message}")
}.onSuccess{ value ->
value.data.forEach { channel ->
println("Channel ID: ${channel.id}, Name: ${channel.name}")
}
}
}
def callback(response, status):
if status.is_error():
print(f"Error fetching channel metadata: {status.error_message}")
else:
for channel in response.data:
print(f"Channel ID: {channel[' id']}, Name: {channel[' name']}, Updated: {channel[' updated']}")
pubnub.get_all_channel_metadata() \
.filter("updated >= '2023-01-01T00:00:00Z'") \
.pn_async(callback)
Digit
Get all users with IDs that do not contain 8
.
- JavaScript
- Swift
- Kotlin
- Python
pubnub.objects.getAllUUIDMetadata({
filter: '!(id LIKE "*8*")'
})
pubnub.allUUIDMetadata(
filter: "!(id LIKE "*8*")",
completion: { result in
switch result {
case .success(let response):
let uuids = response.uuids
print("Fetched UUID Metadata: \(uuids)")
case .failure(let error):
print("Failed to fetch UUID Metadata: \(error.localizedDescription)")
}
}
)
pubnub.getAllUUIDMetadata(
filter = "!(id LIKE "*8*")"
).async { result ->
result.onFailure { exception ->
println("Error fetching UUID metadata: ${exception.message}")
}.onSuccess { value ->
value.data.forEach { metadata ->
println("UUID: ${metadata.id}, Name: ${metadata.name}")
}
}
}
def callback(response, status):
if status.is_error():
print(f"Error fetching UUID metadata: {status.error_message}")
else:
for uuid_data in response.data:
print(f"UUID: {uuid_data['id']}, Name: {uuid_data['name']}")
pubnub.get_all_uuid_metadata()
.filter("!(id LIKE "*8*")")
.pn_async(callback)
Hex digit
Retrieve all channels with IDs containing A3F9
.
- JavaScript
- Swift
- Kotlin
- Python
pubnub.objects.getAllChannelMetadata({
filter: 'id LIKE "*A3F9*"'
})
pubnub.allChannelMetadata(
filter: "id LIKE '*A3F9*'",
completion: { result in
switch result {
case .success(let data):
let channels = data.channels
print("Filtered Channels: \(channels)")
case .failure(let error):
print("Error fetching channel metadata: \(error.localizedDescription)")
}
}
)
pubnub.getAllChannelMetadata(
filter = "id LIKE '*A3F9*'"
).async { result ->
result.onFailure { exception ->
println("Error fetching channel metadata: ${exception.message}")
}.onSuccess { value ->
value.data.forEach { channel ->
println("Channel ID: ${channel.id}, Name: ${channel.name}")
}
}
}
def callback(response, status):
if status.is_error():
print(f"Error fetching channel metadata: {status.error_message}")
else:
for channel in response.data:
print(f"Channel ID: {channel['id']}, Name: {channel['name']}, Updated: {channel['updated']}")
pubnub.get_all_channel_metadata() \
.filter("id LIKE '*A3F9*'") \
.pn_async(callback)
Double quote
Find all channels whose descriptions contain the word VIP
.
- JavaScript
- Swift
- Kotlin
- Python
pubnub.objects.getAllChannelMetadata({
filter: "description LIKE \"*VIP*\""
})
pubnub.allChannelMetadata(
filter: "description LIKE \"*VIP*\"",
completion: { result in
switch result {
case .success(let data):
let channels = data.channels
print("Filtered Channels: \(channels)")
case .failure(let error):
print("Error fetching channel metadata: \(error.localizedDescription)")
}
}
)
pubnub.getAllChannelMetadata(
filter = "description LIKE \"*VIP*\""
).async { result ->
result.onFailure { exception ->
println("Error fetching channel metadata: ${exception.message}")
}.onSuccess { value ->
value.data.forEach { channel ->
println("Channel ID: ${channel.id}, Name: ${channel.name}")
}
}
}
def callback(response, status):
if status.is_error():
print(f"Error fetching channel metadata: {status.error_message}")
else:
for channel in response.data:
print(f"Channel ID: {channel['id']}, Name: {channel['name']}, Updated: {channel['updated']}")
pubnub.get_all_channel_metadata() \
.filter("description LIKE \"*VIP*\"") \
.pn_async(callback)
Unicode character
Retrieve all channel descriptions that contain the ❤️
emoji.
- JavaScript
- Swift
- Kotlin
- Python
pubnub.objects.getAllChannelMetadata({
filter: 'description LIKE "*❤️*"'
})
pubnub.allChannelMetadata(
filter: "description LIKE '*❤️*'",
completion: { result in
switch result {
case .success(let data):
let channels = data.channels
print("Filtered Channels: \(channels)")
case .failure(let error):
print("Error fetching channel metadata: \(error.localizedDescription)")
}
}
)
pubnub.getAllChannelMetadata(
filter = "description LIKE '*:heart:*'"
).async { result ->
result.onFailure { exception ->
println("Error fetching channel metadata: ${exception.message}")
}.onSuccess { value ->
value.data.forEach { channel ->
println("Channel ID: ${channel.id}, Name: ${channel.name}")
}
}
}
def callback(response, status):
if status.is_error():
print(f"Error fetching channel metadata: {status.error_message}")
else:
for channel in response.data:
print(f"Channel ID: {channel['id']}, Name: {channel['name']}, Updated: {channel['updated']}")
pubnub.get_all_channel_metadata() \
.filter("description LIKE '*❤️*'") \
.pn_async(callback)
Special character
Get metadata of a channel with a specific description containing a new line.
- JavaScript
- Swift
- Kotlin
- Python
pubnub.objects.getAllChannelMetadata({
filter: 'description == "Check out our new deals!\nAvailable for a limited time."'
})
pubnub.allChannelMetadata(
filter: "description == 'Check out our new deals!\nAvailable for a limited time.'",
completion: { result in
switch result {
case .success(let data):
let channels = data.channels
print("Filtered Channels: \(channels)")
case .failure(let error):
print("Error fetching channel metadata: \(error.localizedDescription)")
}
}
)
pubnub.getAllChannelMetadata(
filter = "description == 'Check out our new deals!\nAvailable for a limited time.'"
).async { result ->
result.onFailure { exception ->
println("Error fetching channel metadata: ${exception.message}")
}.onSuccess { value ->
value.data.forEach { channel ->
println("Channel ID: ${channel.id}, Name: ${channel.name}")
}
}
}
def callback(response, status):
if status.is_error():
print(f"Error fetching channel metadata: {status.error_message}")
else:
for channel in response.data:
print(f"Channel ID: {channel['id']}, Name: {channel['name']}, Updated: {channel['updated']}")
pubnub.get_all_channel_metadata() \
.filter("description == 'Check out our new deals!\nAvailable for a limited time.'") \
.pn_async(callback)