Buckets and KiiObjects
In order to store data in Kii Cloud, you create buckets in one of the scopes and create KiiObjects in the buckets.
For an overview of buckets and KiiObjects, see Mobile Features in the Getting Started guide. Review this linked topic if you have not.
As described in the Getting Started guide, you can create a bucket in any of the application scope, group scopes, or user scopes. A bucket can be created also in a thing scope for your IoT solution.
A bucket in the application scope is accessible to any user. A bucket in a user or group scope is accessible to the user or group that owns the scope.
There are various advantages in using buckets. The purposes of using buckets are as follows:
You can organize data as KiiObjects stored in buckets so that the data can be easily managed by your service.
A search query is executed against a bucket for KiiObjects. You can execute a single query and quickly retrieve KiiObjects that meet the search criteria by grouping KiiObjects of the same type in a single bucket.
You can individually configure access rights of each bucket with its ACL. You can easily customize the security setting by putting data for specific users and groups in a bucket and configuring the bucket's ACL.
A KiiObject is a data structure that can hold a JSON document (key-value pairs) and an object body (a file).
JSON document (key-value pairs)
The Kii Cloud SDK provides functions that read and write key-value pairs in the JSON document. The Kii Cloud SDK enables simple implementation with the flexibility of JSON by accessing the JSON document with a method such as the
object.set(key, value)without any JSON parser.
You can represent nested data with a JSON document that has a hierarchy of multiple levels by setting a JSON object as a value for a key.
The JSON format allows you to manipulate data on different OSes. You can easily read data on an iOS device even if the data was written on an Android device.
The object body feature allows you to attach large data such as a file to a KiiObject.
For a future overview, see Using Object Bodies.
You can create various data structures that serve the specification of your service by optimizing the design of buckets and KiiObjects.
For example, suppose you need to save configuration data and messages for a chat service. It is appropriate to store configuration data in buckets in each user's scope because such data should be saved per user. On the other hand, messages should be stored in a bucket in each group's scope because the group members share messages.
Besides, you can keep data private by storing it in a bucket in each user's scope, for example in a health management app.
Access to buckets is scalable. User growth does not affect the performance unless you encounter an issue such as a bottleneck caused because all the users access a single bucket.
All you need to do for creating a data structure is just saving data from the mobile app.
Your client implementation team can promptly build necessary features without server-side implementation nor administrative configuration.