Custom Fields and Queries
Using custom fields and querying them in Thread and Store containers.
Custom fields and querying them is a functionality that works with Threads and Stores containers.
It allows you to define new fields by placing them in the publicMeta
of a container or an object within a given container,
and then querying the PrivMX Endpoint Client (using existing listing methods) for elements containing these previously defined fields.
Sample code on this page is based on the initial assumptions.
Working with Custom Fields and Queries
Below there is a simple code example of how to add a custom field to a batch of Threads, and then search for them using custom query.
Initial Setup
Let's add some required includes and initialize the PrivMX Endpoint Client with the Thread API:
Defining a Sample Custom Field
Creating Threads
The following code will create a total of 6 new Threads. 3 of them will contain a Custom Field.
Listing Threads
The next piece of code will demonstrate how you can filter the results of the listThreads(...)
method using built-in it Custom Queries functionality
to get the Threads containing the previously defined Custom Field.
The results of the example above will look similar to those below:
A full code example can be found on Simplito's GitHub.
We use cookies on our website. We use them to ensure the proper functioning of the site and, if you agree, for purposes we set, such as analytics or marketing.