DXDataClient
This class is responsible for making requests to the DX data API.
The DXDataClient
class allows you to create and update buckets to store your app's data. Buckets can be created for a single user for private data. or for multiple users, allowing them to access shared data. Buckets are essentially JSON objects with key-value pairs and can be updated by creating and writing to a new key, or overwriting an existing one.
You will need to enable the "Lightning Database" scope for your app in the developer dashboard before using the data API.
Properties
Singleton instance of DXDataClient
. You will access all the available DXDataClient
methods through this instance.
Methods
readPrivateData
Read a user's private app data.
writePrivateData
Update a user's private app data.
create
Create a named bucket and specify what users have access to it. By default, the user creating the bucket (the currently authenticated user) will have access to the bucket.
write
Write data to a bucket at a key. If key is an empty String
, the bucket will be overwritten with the value provided. If the key does not exist in the bucket, it will be created in the bucket as a key-value pair. All data written to a bucket has to conform to Swift's Codable
protocol (introduced in version 4.2), as it will otherwise cause an error when attempting to serialize the value to JSON. For more information on Codable
, check out this link.
Attempting to write to a bucket that hasn't been created will return an error.
read
Read data from a bucket. If a key is provided, it will read data from that key in the bucket.
Attempting to read from a bucket that hasn't been created will return an error.
readAllBuckets
Read all buckets that the current user has access to. Will return an array of the buckets' names.
delete
Delete a key in the bucket, including all nested data at that key.
Attempting to delete a key in a bucket that hasn't been created will return an error.
delete
Delete an entire bucket.
Attempting to delete a bucket that hasn't been created will return an error.
Last updated