curl -X PUT \
-H "Content-Type: application/json" \
-H "QB-token: c8d706877dc40c4f56f8be618dda898456013152" \
-d '{
"game_mode_name":"rainbow dash",
}' \
https://api.quickblox.com/data/ScoreTable/5f60e245a28f9a78e6c07322.json \
{
"_id": "5f60e245a28f9a78e6c07322",
"_parent_id": null,
"created_at": 1600184901,
"expert_mode": null,
"game_mode_name": "rainbow dash",
"name": null,
"progress": 0,
"score_value": null,
"updated_at": 1600184901,
"user_id": 102433734,
"permissions": {
"read": {
"access": "open"
},
"update": {
"access": "owner"
},
"delete": {
"access": "owner"
}
}
}
Update Record
Update an existing record.
curl -X PUT \
-H "Content-Type: application/json" \
-H "QB-token: c8d706877dc40c4f56f8be618dda898456013152" \
-d '{
"game_mode_name":"rainbow dash",
}' \
https://api.quickblox.com/data/ScoreTable/5f60e245a28f9a78e6c07322.json \
{
"_id": "5f60e245a28f9a78e6c07322",
"_parent_id": null,
"created_at": 1600184901,
"expert_mode": null,
"game_mode_name": "rainbow dash",
"name": null,
"progress": 0,
"score_value": null,
"updated_at": 1600184901,
"user_id": 102433734,
"permissions": {
"read": {
"access": "open"
},
"update": {
"access": "owner"
},
"delete": {
"access": "owner"
}
}
}
Recipes
Add/remove value from record array
Add/remove value from record array
1. Set an update operator for an array field to add values to the array
add_to_set operator to an array field to add values to the array. Here, the add_to_set operator is applied to the films field with new values that should be added to the array.curl -X PUT \
-H "Content-Type: application/json" \
-H "QB-Token: c3cd44309db1405472627e7a5cb436278e012bba" \
-d '{
"add_to_set":{
"films":[
"The Shawshank Redemption",
"Aladdin"
]
},
"pull":{
"ratings":{
"lt":3
}
}
}' \
"https://api.quickblox.com/data/Cinemas/5d87a916a28f9a683f1cb55d.json"
2. Set an update operator for another array field to remove values from the array
pull operator to the array field to remove values from the array. Here, the pull operator is applied to the ratings field with the values that should be removed from its array.curl -X PUT \
-H "Content-Type: application/json" \
-H "QB-Token: c3cd44309db1405472627e7a5cb436278e012bba" \
-d '{
"add_to_set":{
"films":[
"The Shawshank Redemption",
"Aladdin"
]
},
"pull":{
"ratings":{
"lt":3
}
}
}' \
"https://api.quickblox.com/data/Cinemas/5d87a916a28f9a683f1cb55d.json"
3. As a result, the API returns the updated record.
films array and removed from the ratings array.{
"_id": "5d87a916a28f9a683f1cb55d",
"_parent_id": null,
"created_at": 1569248534,
"films": [
"The Shawshank Redemption",
"Aladdin"
],
"ratings": [],
"updated_at": 1569252134,
"user_id": 96753878,
"permissions": {
"read": {
"access": "open"
},
"update": {
"access": "owner"
},
"delete": {
"access": "owner"
}
}
}
Increment/append value of record array
Increment/append value of record array
1. Set an update operator for an array field to increment values of an array
inc operator to an array field to increment its values. Here, the inc operator is applied to the score_value and progress fields.curl -X PUT \
-H "Content-Type: application/json" \
-H "QB-Token: c3cd44309db1405472627e7a5cb436278e012bba" \
-d '{
"inc":{
"score_value":20,
"progress":0.11
},
"push":{
"completed_levels":[
4
]
}
}' \
"https://api.quickblox.com/data/ScoreTable/5d866b53a28f9a5ad51cb562.json"
2. Set an update operator for another array field to append values to it
push operator to the array to append values to it. Here, the push operator is applied to the completed_levels field with the values that should be appended.curl -X PUT \
-H "Content-Type: application/json" \
-H "QB-Token: c3cd44309db1405472627e7a5cb436278e012bba" \
-d '{
"inc":{
"score_value":20,
"progress":0.11
},
"push":{
"completed_levels":[
4
]
}
}' \
"https://api.quickblox.com/data/ScoreTable/5d866b53a28f9a5ad51cb562.json"
3. As a result, the API returns the updated record.
4 value is appended to the completed_levels array while the score_value and progress values are incremented by the 20 and 0.11.{
"_id": "5d866b53a28f9a5ad51cb562",
"_parent_id": null,
"completed_levels": [
1,
2,
3,
4
],
"created_at": 1569090387,
"progress": 0.34,
"score_value": 1020,
"updated_at": 1569252134,
"user_id": 96753878,
"permissions": {
"read": {
"access": "open"
},
"update": {
"access": "owner"
},
"delete": {
"access": "owner"
}
}
}
Update record array element by index
Update record array element by index
1. Set an array element
curl -X PUT \
-H "Content-Type: application/json" \
-H "QB-Token: c3cd44309db1405472627e7a5cb436278e012bba" \
-d '{
"movie[<1>]":"Titatic",
}' \
"https://api.quickblox.com/data/ScoreTable/5f60e245a28f9a78e6c07322.json" \
2. As a result, the API returns an updated array.
movie array is updated to Titanic.{
"_id": "5f60e245a28f9a78e6c07322",
"_parent_id": null,
"created_at": 1600184901,
"movie": [
"Star Wars",
"Titanic"
],
"updated_at": 1600184901,
"user_id": 102433734,
"permissions": {
"read": {
"access": "open"
},
"update": {
"access": "owner"
},
"delete": {
"access": "owner"
}
}
}
Update record
Update record
1. Set a new value for a field
game_mode_name field is set to rainbow dash.curl -X PUT \
-H "Content-Type: application/json" \
-H "QB-token: c8d706877dc40c4f56f8be618dda898456013152" \
-d '{
"game_mode_name":"rainbow dash",
}' \
"https://api.quickblox.com/data/ScoreTable/5f60e245a28f9a78e6c07322.json" \
2. As a result, the API returns an updated record.
{
"_id": "5f60e245a28f9a78e6c07322",
"_parent_id": null,
"created_at": 1600184901,
"expert_mode": null,
"game_mode_name": "rainbow dash",
"name": null,
"progress": 0,
"score_value": null,
"updated_at": 1600184901,
"user_id": 102433734,
"permissions": {
"read": {
"access": "open"
},
"update": {
"access": "owner"
},
"delete": {
"access": "owner"
}
}
}
Add/remove value from record array with API key
Add/remove value from record array with API key
1. Use 'Authorization' header to pass API key
curl -X PUT \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
-d '{
"add_to_set":{
"films":[
"The Shawshank Redemption",
"Aladdin"
]
},
"pull":{
"ratings":{
"lt":3
}
}
}' \
"https://api.quickblox.com/data/Cinemas/5d87a916a28f9a683f1cb55d.json"
2. Set an update operator for an array field to add values to the array
add_to_set operator to an array field to add values to the array. Here, the add_to_set operator is applied to the films field with new values that should be added to the array.curl -X PUT \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
-d '{
"add_to_set":{
"films":[
"The Shawshank Redemption",
"Aladdin"
]
},
"pull":{
"ratings":{
"lt":3
}
}
}' \
"https://api.quickblox.com/data/Cinemas/5d87a916a28f9a683f1cb55d.json"
3. Set an update operator for another array field to remove values from the array
pull operator to the array field to remove values from the array. Here, the pull operator is applied to the ratings field with the values that should be removed from its array.curl -X PUT \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
-d '{
"add_to_set":{
"films":[
"The Shawshank Redemption",
"Aladdin"
]
},
"pull":{
"ratings":{
"lt":3
}
}
}' \
"https://api.quickblox.com/data/Cinemas/5d87a916a28f9a683f1cb55d.json"
4. As a result, the API returns the updated record.
films array and removed from the ratings array.{
"_id": "5d87a916a28f9a683f1cb55d",
"_parent_id": null,
"created_at": 1569248534,
"films": [
"The Shawshank Redemption",
"Aladdin"
],
"ratings": [],
"updated_at": 1569252134,
"user_id": 96753878,
"permissions": {
"read": {
"access": "open"
},
"update": {
"access": "owner"
},
"delete": {
"access": "owner"
}
}
}
Increment/append value of record array with API key
Increment/append value of record array with API key
1. Use 'Authorization' header to pass API key
curl -X PUT \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
-d '{
"inc":{
"score_value":20,
"progress":0.11
},
"push":{
"completed_levels":[
4
]
}
}' \
"https://api.quickblox.com/data/ScoreTable/5d866b53a28f9a5ad51cb562.json"
2. Set an update operator for an array field to increment values of an array
inc operator to an array field to increment its values. Here, the inc operator is applied to the score_value and progress fields.curl -X PUT \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
-d '{
"inc":{
"score_value":20,
"progress":0.11
},
"push":{
"completed_levels":[
4
]
}
}' \
"https://api.quickblox.com/data/ScoreTable/5d866b53a28f9a5ad51cb562.json"
3. Set an update operator for another array field to append values to it
push operator to the array to append values to it. Here, the push operator is applied to the completed_levels field with the values that should be appended.curl -X PUT \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
-d '{
"inc":{
"score_value":20,
"progress":0.11
},
"push":{
"completed_levels":[
4
]
}
}' \
"https://api.quickblox.com/data/ScoreTable/5d866b53a28f9a5ad51cb562.json"
4. As a result, the API returns the updated record.
4 value is appended to the completed_levels array while the score_value and progress values are incremented by the 20 and 0.11.{
"_id": "5d866b53a28f9a5ad51cb562",
"_parent_id": null,
"completed_levels": [
1,
2,
3,
4
],
"created_at": 1569090387,
"progress": 0.34,
"score_value": 1020,
"updated_at": 1569252134,
"user_id": 96753878,
"permissions": {
"read": {
"access": "open"
},
"update": {
"access": "owner"
},
"delete": {
"access": "owner"
}
}
}
Update record array element by index with API key
Update record array element by index with API key
1. Use 'Authorization' header to pass API key
curl -X PUT \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
-d '{
"movie[<1>]":"Titatic",
}' \
"https://api.quickblox.com/data/ScoreTable/5f60e245a28f9a78e6c07322.json" \
2. Set an array element
curl -X PUT \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
-d '{
"movie[<1>]":"Titatic",
}' \
"https://api.quickblox.com/data/ScoreTable/5f60e245a28f9a78e6c07322.json" \
3. As a result, the API returns an updated array.
movie array is updated to Titanic.{
"_id": "5f60e245a28f9a78e6c07322",
"_parent_id": null,
"created_at": 1600184901,
"movie": [
"Star Wars",
"Titanic"
],
"updated_at": 1600184901,
"user_id": 102433734,
"permissions": {
"read": {
"access": "open"
},
"update": {
"access": "owner"
},
"delete": {
"access": "owner"
}
}
}
Update record with API key
Update record with API key
1. Use 'Authorization' header to pass API key
curl -X PUT \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
-d '{
"game_mode_name":"rainbow dash",
}' \
"https://api.quickblox.com/data/ScoreTable/5f60e245a28f9a78e6c07322.json" \
2. Set a new value for a field
game_mode_name field is set to rainbow dash.curl -X PUT \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
-d '{
"game_mode_name":"rainbow dash",
}' \
"https://api.quickblox.com/data/ScoreTable/5f60e245a28f9a78e6c07322.json" \
3. As a result, the API returns an updated record.
{
"_id": "5f60e245a28f9a78e6c07322",
"_parent_id": null,
"created_at": 1600184901,
"expert_mode": null,
"game_mode_name": "rainbow dash",
"name": null,
"progress": 0,
"score_value": null,
"updated_at": 1600184901,
"user_id": 102433734,
"permissions": {
"read": {
"access": "open"
},
"update": {
"access": "owner"
},
"delete": {
"access": "owner"
}
}
}
PUT request with application/json or
application/x-www-form-urlencoded content type of PUT/POST body. Received values will be casted according to
the class defined in QuickBlox Dashboard.
A field that is present in class but not specified in the PUT request has a null value. To nullify
the existing value you should specify null for application/x-www-/form-urlencoded, and null
for application/json content type.
An update request updates specified fields only (other fields will be left untouched).
For numeric fields Integer and Float, there is a special increment operator inc
that increments or decrements the numeric field.
Update operators
The request can contain next update operators:
| Operator | Description |
|---|---|
| inc | Types: integer, float Example: inc[field1]=1000 Increment field <field_name> to a specified value. The value can be positive or negative(decrement operation). |
| pull | Types: arrays Example: pull[field1]=val1 Removes a specified value from the array field. |
| pull with filter | Types: arrays Example: pull[field1][<filter_operator>]=<filter_value> Removes all elements filtered by filter operator from the array. |
| pull_all | Types: arrays Example: pull_all[field1][]=val1&pull_all[field1][]=val2 Removes all specified values from the array. |
| pop | Types: arrays Example: pop[field1]=1 Removes the last element from the array. To remove the first, the element value should be equal to 1. |
| push | Types: arrays Example: push[field1][]=val1&push[field1][]=val2 Appends specified values to the array. |
| add_to_set | Types: arrays Example: add_to_set[<field_name>]= Adds a value to the array only if the value is not in the array already. |
| Update array element by index operator | Type: arrays Example: <field_name>[<index>]=val Update the array element by index. |
| Operator | Description |
|---|---|
| lt | Less Than operator Types:integer, float Example: score_value[lt]=1000 |
| lte | Less Than or Equal to operator Types: integer, float Example: score_value[lte]=850 |
| gt | Greater Than operator Types: integer, float Example: bonus_count[gt]=2.45 |
| gte | Greater Than or Equal to operator Types: integer, float Example: bonus_count[gte]=56.443 |
| ne | Not Equal to operator Types: integer, float, string, boolean Example: game_mode_name[ne]=ctf |
| in | Contained IN array operator Types: integer, float, string Example: game_mode_name[in]=deathmatch,rage |
| nin | Not contained IN array operator Types: integer, float, string Example: game_mode_name[nin]=survivor,crazy_nightmare |
| all | ALL contained IN array operator Types: array Example: game_modes[all]=survivo,crazy |
| or | OR operator Types: integer, float, string Example: name[or]=sam,tim name[or]=sam&lastname[or]=johnson Will return records with name sam or tim. Will return records with name sam or last name johnson. |
| ctn | Contains substring operator Types: string Example: username[ctn]=son Will return all records where username field contains son substring. |
| near | Types: location Example: mylocation[near]=25.32,44.551;1000 Search records in a specific radius with the current position in meters. Format: {field_name}[near]=longitude,latitude;radius. |
| Permission | Syntax | Example |
|---|---|---|
| Open | permissions.<CRUD_operation>.access | permissions.read.access=open |
| Owner | permissions.<CRUD_operation>.access | permissions.read.access=owner |
| Open for users IDs | permissions.<CRUD_operation>.access=open_for_users_ids permissions.<CRUD_operation>.ids=id_1,id_2,id_3,… | permissions.update.access=open_for_users_ids permissions.update.ids=3,12 |
| Open for groups | permissions.<CRUD_operation>.access=open_for_groups permissions.<CRUD_operation>.groups=group_name_1,group_name_2 | permissions.delete.access=open_for_groups permissions.delete.groups=experience,rate |
Path Parameters
Body Parameters
cartoons[1]=Aladdin.Show properties
Show properties
Show propeties
Show propeties
Show {custom_array_field_M} object
Show {custom_array_field_M} object
Show properties
Show properties
Show properties
Show properties
Show properties
Show properties
Show properties
Show properties
permission.<CRUD_operation>.access=<value> permission.<CRUD_operation>.<option>=<value>CRUD operations: create, read, update, delete. CRUD access values:
open, owner, open_for_users_ids, open_for_groups. CRUD options:
ids, groups.Headers
ApiKey {your_api_key}. Must be used
either QB-Token or Authorization.Responses
curl -X PUT \
-H "Content-Type: application/json" \
-H "QB-token: c8d706877dc40c4f56f8be618dda898456013152" \
-d '{
"game_mode_name":"rainbow dash",
}' \
https://api.quickblox.com/data/ScoreTable/5f60e245a28f9a78e6c07322.json \
{
"_id": "5f60e245a28f9a78e6c07322",
"_parent_id": null,
"created_at": 1600184901,
"expert_mode": null,
"game_mode_name": "rainbow dash",
"name": null,
"progress": 0,
"score_value": null,
"updated_at": 1600184901,
"user_id": 102433734,
"permissions": {
"read": {
"access": "open"
},
"update": {
"access": "owner"
},
"delete": {
"access": "owner"
}
}
}
Was this page helpful?