App Context API for PubNub Ruby SDK
App Context provides easy-to-use, serverless storage for user and channel data you need to build innovative, reliable, scalable applications. Use App Context 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 real time and update their front-end application accordingly.
User
Get Metadata for All Users
Returns a paginated list of UUID Metadata objects, optionally including the custom data object for each.
Method(s)
To Get All UUID Metadata
you can use the following method(s) in the Ruby SDK:
get_all_uuid_metadata(
sort: sort,
include: include,
filter: filter,
start: start,
end: end,
limit: limit,
http_sync: http_sync,
callback: callback
)
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
sort | Array | Optional | List of criteria (name of field) which should be used for sorting in ascending order. Available options are id , name , and updated . Use asc or desc to specify sort direction. | |
include | Object | Optional | { count: true } | Additional information which should be included in response. Available options:
|
filter | String | Optional | Expression to filter out results basing on specified criteria. For more details on the supported grammar, check here | |
start | String | Optional | Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off. | |
end | String | Optional | Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data. Ignored if the start parameter is supplied. | |
limit | Integer | Optional | 100 | Number of objects to return in response. Default is 100 , which is also the maximum value. |
http_sync | Boolean | Optional | false | Method will be executed asynchronously and will return future, to get its value you can use value method. If set to true , method will return array of envelopes (even if there's only one envelope ). For sync methods Envelope object will be returned. |
callback | Lambda accepting one parameter | Optional | Callback that will be called for each envelope. For async methods future will be returned, to retrieve value Envelope object you have to call value method (thread will be locked until the value is returned). |
Basic Usage
pubnub.get_all_uuid_metadata(
limit: 5,
include: { custom: true }
) do |envelope|
puts envelope
end
Response
#<Pubnub::Envelope
@result = {
:data => {
:metadata => [
{
:id => "mg",
:name => "magnum",
:externalId => nil,
:profileUrl => nil,
:email => nil,
:custom => { "XXX" => "YYYY" },
:updated => <Date>,
:eTag => "Ad2eyIWXwJzBqAE"
}
],
show all 24 linesGet User Metadata
Returns metadata for the specified UUID, optionally including the custom data object for each.
Method(s)
To Get UUID Metadata
you can use the following method(s) in the Ruby SDK:
get_uuid_metadata(
uuid: uuid,
include: include,
http_sync: http_sync,
callback: callback
)
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
uuid | String | Optional | Client UUID | Identifier for which associated metadata should be fetched. Default: configured PubNub client uuid . |
include | Object | Optional | { custom: true } | Additional information which should be included in response. Available options:
|
http_sync | Boolean | Optional | false | Method will be executed asynchronously and will return future, to get its value you can use value method. If set to true , method will return array of envelopes (even if there's only one envelope ). For sync methods Envelope object will be returned. |
callback | Lambda accepting one parameter | Optional | Callback that will be called for each envelope. For async methods future will be returned, to retrieve value Envelope object you have to call value method (thread will be locked until the value is returned). |
Basic Usage
pubnub.get_uuid_metadata(include: { custom: true }) do |envelope|
puts envelope
end