Data Storage: Storing data against entities and extensions
Entity Properties
What is a key-value pair?
'Key-value' is a format in which data can be stored. You can store the property or an attribute of an entity or an extension in a key-value pair. The key will be a unique string and the value will be a JSON object. Data like session information, user profiles, and preferences can be stored as key-value pairs. You can store data against the entities we support and the extensions you develop for Zoho Projects.
Storing data against an entity
Zoho Projects supports the Project, Task and Issue entities. You will be able to store project-specific, task-specific or issue-specific data against their respective entities. The key will be a unique string and the data will be a JSON object that has to be identified with the key in the future. You can store, retrieve, update, and delete the data that you store against an entity using the following methods respectively.
entity.store
var value = [
{"id" : "1-QabBt69U8myXYRDVU-1YiCo2k-JWRfu","name" : "Sample.png"}
];
var count = 1;
zohoprojects.entity.store("6573492", value, count).then(function(response)
/* Output
{
"properties": [
{
"key": "6573492",
"value": "[{\"id\":\"1-QabBt69U8myXYRDVU-1YiCo2k-JWRfu\",\"name\":\"sample.png\"}]",
"count" : 1,
"id": 1587134426
}
]
}
*/
);
Argument name | Data type | Description |
key | string |
Unique string used to identify the entity property. Only this key should be used to retrieve the data later. Note: Max length: <200> TBD |
value | JSONObject | Property / Data that has to be stored against the entity. |
count | Integer | Number of occurrences stored against the entity. |
entity.retrieve
zohoprojects.entity.retrieve("6573492").then(function(response)
/*Output
{
"properties": [
{
"key": "6573492",
"value": "[{\"id\":\"1-QabBt69U8myXYRDVU-1YiCo2k-JWRfu\",\"name\":\"update.png\"}]",
"id": 1587134426,
"count: 1
}
]
}
*/
);
entity.update
Argument name | Data type | Description |
id | string | The ID that was generated as the output while storing the current key against the entity using the entity.store() method. |
key | string | The new key has to be mapped against the entity. You can also choose to retain the old/current key. |
value | JSON Object | The data or property that has to be updated against the entity. |
count | Integer | Number of occurrences updated against the entity. |
var valueObj = [
{"id" : "1-QabBt69U8myXYRDVU-1YiCo2k-JWRfu","name" : "Sample_New.png"}
];
zohoprojects.entity.update({id:"1587134426",key:"6573492",value:valueObj,count:2}).then(function(response)
/*Output
{
"properties": [
{
"key": "6573492",
"value": "[{\"id\":\"1-QabBt69U8myXYRDVU-1YiCo2k-JWRfu\",\"name\":\"Sample_New.png\"}]",
"id": 1587134426,
"count" : 2
}
]
}
*/
);
entity.remove
zohoprojects.entity.remove(1587134426).then(function(response)
/* Output
{
"status": "success"
}
*/
);
Limitations of entity properties
- The value stored against a key should not exceed 50KB at once.
- This method cannot be invoked for the 'app_settings', 'attachment_picker', 'blueprint_during', and 'top_band' locations.
- The value stored in an entity property should be in a valid JSON format.
- Concurrent edits on an entity property don't ensure consistency. i.e, when two different users make changes to the same entity property at the same time, only the latest change will be saved and the former will be lost/overridden.
Extension property
What is an extension property?
It is a key-value pair that's stored against the extension itself. However, the data stored against an extension will be lost if the extension is uninstalled from the product. Whereas, the data stored against an entity will be retained even if the extension is uninstalled because only the extension-specific information gets deleted and the entity-specific data will still be available for the other extensions to access.
app.store
var value = [
{"id" : "1-QabBt69U8myXYRDVU-1YiCo2k-JWRfu","name" : "Sample.png"}
];
zohoprojects.app.store("6573492", value).then(function(response)
/* Output
{
"properties": [
{
"key": "6573492",
"value": "[{\"id\":\"1-QabBt69U8myXYRDVU-1YiCo2k-JWRfu\",\"name\":\"sample.png\"}]",
"id": 1587134426
}
]
}
*/
);
Argument name | Data type | Description |
key | string | Unique string used to identify the extension property. |
value | JSONObject | Property/Data that has to be stored against the extension. |
app.retrieve
Retrieves the data stored against the extension. The argument of this method should be the key that was used when the same was stored. Data could be retrieved only when this method is invoked from the extension against which it is stored. When the extension is uninstalled, the data will be deleted.
zohoprojects.app.retrieve("6573492").then(function(response)
/*Output
{
"properties": [
{
"key": "6573492",
"value": "[{\"id\":\"1-QabBt69U8myXYRDVU-1YiCo2k-JWRfu\",\"name\":\"update.png\"}]",
"id": 1587134426
}
]
}
*/
);
app.update
Argument name | Data type | Description |
id | string | The ID that was generated as the output while storing the current key against the extension using the app.store() method. |
key | string | The new key that has to be mapped against the extension. You can also choose to retain the old/current key. |
value | JSON Object | The data or property that has to be updated against the extension. |
var valueObj = [
{"id" : "1-QabBt69U8myXYRDVU-1YiCo2k-JWRfu","name" : "Sample_New.png"}
];
zohoprojects.app.update({id:"1587134426",key:"6573492",value:valueObj}).then(function(response)
/*Output
{
"properties": [
{
"key": "6573492",
"value": "[{\"id\":\"1-QabBt69U8myXYRDVU-1YiCo2k-JWRfu\",\"name\":\"Sample_New.png\"}]",
"id": 1587134426
}
]
}
*/
);
app.remove
zohoprojects.app.remove(1587134426).then(function(response)
/* Output
{
"status": "success"
}
*/
);
Limitations of extension properties
- The value stored against a key should not exceed 50KB at once.
- A maximum of 100 key-value pairs only can be stored per extension.
- The value stored in an extension property should be in a valid JSON format.
- Concurrent edits on an extension property don't ensure consistency. i.e, when two different users make changes to the same extension property at the same time, only the latest change will be saved and the former will be lost/overridden.