_id
, user_id
, parent_id
, created_at
, and updated_at
.
Allowed data types: Integer (or Array of Integer); String (or Array of String); Float (or Array of Float); Boolean (or Array of Boolean); Location (Array of [< longitude >, < latitude >]); File; Date.
Visit Key Concepts page to learn the most important QuickBlox concepts.
Before you begin
- Register a QuickBlox account. This is a matter of a few minutes and you will be able to use this account to build your apps.
- Configure QuickBlox SDK for your app. Check out Setup page for more details.
- Create a user session to be able to use QuickBlox functionality. See Authenfication page to learn how to do it.
Create class
To start using Custom Objects module, create a class:- Go to QuickBlox Dashboard.
- Follow Custom => Add => Add new class direction. As a result, Add new class popup will appear.
- Enter a class name, add any fields you want.
- Click Create class button to create a new class.
Create records
To create a single object, use the code snippet below.JavaScript
JavaScript
Retrieve records by IDs
To get records with a particular record ID, use thegetByIds()
method. Set the record ID using the objectsIds
field of the query
object. Go over Sort operators and Search operators sections to learn about filters and search operators you can use to retrieve records.
JavaScript
getByIds()
method accepts one argument of the object type that has the following fields:
Fields | Required | Description |
---|---|---|
className | yes | Name of a custom object class. |
objectsIds | yes | Custom objects IDs. |
Retrieve records
You can search for records of a particular class. The request below will return records of theRNCustomObject2
class, with the value
greater than 1000
, sorted by the created_at
field in descending order.
JavaScript
get()
method accepts one argument of the object type with the following fields:
Field | Required | Description |
---|---|---|
className | yes | A name of a custom object class. |
filter | no | Specifies filtering criteria for the field. |
sort | no | Specifies sorting criteria for the field. |
skip | no | Skip N records in search results. Useful for pagination. Default (if not specified): 0. |
limit | no | Limit search results to N records. Useful for pagination. Default value: 100. |
Search operators
You can use search operators to get more specific search results. The request below will return records of theAppointment
class by the priority
field with the value less than 1
, sorted in descending order by the updated_at
field.
JavaScript
QB.objects.OBJECTS_SEARCH_OPERATOR
object to find out what search operators you can use. It contains several operators separated by value type. Here are the search operators that you can use to search for the exact data that you need.
Search operators | Applicable to types | Description |
---|---|---|
lt | integer, float | Less Than operator. |
lte | integer, float | Less Than or Equal to operator. |
gt | integer, float | Greater Than operator. |
gte | integer, float | Greater Than or Equal to operator. |
ne | integer, float, string, boolean | Not Equal to operator. |
in | integer, float, string | IN array operator. |
or | integer, float, string | All records that contain a value 1 or value 2. |
nin | integer, float, string | Not IN array operator. |
all | array | ALL are contained in array. |
ctn | string | All records that contain a particular substring. |
Sort operators
You can use sort operators to order the search results. The request below will return 10 records of theAppointment
class sorted in descending by the priority
field.
JavaScript
Sort options | Applicable to types | Description |
---|---|---|
ascending | All types | Sort results in the ascending order by setting the ascending as true. |
decsending | All types | Sort results in the descending order by setting the ascending as false. |
Update records
You can update a single record using the code snippet below.JavaScript
JavaScript
Delete records
To delete a single record, use the code snippet below.JavaScript
JavaScript
Relations
It is possible to create a relation between objects of two different classes via_parent_id
field.
For example, we have the class Rating that contains score
, review
, and comment
fields. We also have a Movie class. So we can create a record of class Rating that will point to the record of the class Movie via its _parent_id
field, so the _parent_id
field will contain the ID of record from class Movie.
This is not a simple soft link. This is actually a hard link. When you delete the Movie class record then all its children (records of class Rating with
_parent_id
field set to the Movie class record ID) will be automatically deleted as well.