records
Creates, updates, deletes, gets or lists a records resource.
Overview
| Name | records |
| Type | Resource |
| Id | aws.cognito_sync.records |
Fields
The following fields are returned by SELECT queries:
- list_records
| Name | Datatype | Description |
|---|---|---|
count | integer | Total number of records. |
dataset_deleted_after_requested_sync_count | boolean | A boolean value specifying whether to delete the dataset locally. |
dataset_exists | boolean | Indicates whether the dataset exists. |
dataset_sync_count | integer (int64) | Server sync count for this dataset. |
last_modified_by | string | The user/device that made the last change to this record. |
merged_dataset_names | array | Names of merged datasets. |
next_token | string | A pagination token for obtaining the next page of results. |
records | array | A list of all records. |
sync_session_token | string | A token containing a session ID, identity ID, and expiration. |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
list_records | select | identity_pool_id, identity_id, dataset_name, region | lastSyncCount, nextToken, maxResults, syncSessionToken | Gets paginated records, optionally changed after a particular sync count for a dataset and identity. With Amazon Cognito Sync, each identity has access only to its own data. Thus, the credentials used to make this API call need to have access to the identity data. ListRecords can be called with temporary user credentials provided by Cognito Identity or with developer credentials. You should use Cognito Identity credentials to make this API call. |
update_records | update | identity_pool_id, identity_id, dataset_name, region, SyncSessionToken | x-amz-Client-Context | Posts updates to records and adds and deletes records for a dataset and user. The sync count in the record patch is your last known sync count for that record. The server will reject an UpdateRecords request with a ResourceConflictException if you try to patch a record with a new value but a stale sync count. For example, if the sync count on the server is 5 for a key called highScore and you try and submit a new highScore with sync count of 4, the request will be rejected. To obtain the current sync count for a record, call ListRecords. On a successful update of the record, the response returns the new sync count for that record. You should present that sync count the next time you try to update that same record. When the record does not exist, specify the sync count as 0. This API can be called with temporary user credentials provided by Cognito Identity or with developer credentials. |
Parameters
Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.
| Name | Datatype | Description |
|---|---|---|
dataset_name | string | A string of up to 128 characters. Allowed characters are a-z, A-Z, 0-9, '_' (underscore), '-' (dash), and '.' (dot). |
identity_id | string | A name-spaced GUID (for example, us-east-1:23EC4050-6AEA-7089-A2DD-08002EXAMPLE) created by Amazon Cognito. GUID generation is unique within a region. |
identity_pool_id | string | A name-spaced GUID (for example, us-east-1:23EC4050-6AEA-7089-A2DD-08002EXAMPLE) created by Amazon Cognito. GUID generation is unique within a region. |
region | string | AWS region (default: us-east-1) |
lastSyncCount | integer (int64) | The last server sync count for this record. |
maxResults | integer | The maximum number of results to be returned. |
nextToken | string | A pagination token for obtaining the next page of results. |
syncSessionToken | string | A token containing a session ID, identity ID, and expiration. |
x-amz-Client-Context | string | Intended to supply a device ID that will populate the lastModifiedBy field referenced in other methods. The ClientContext field is not yet implemented. |
SELECT examples
- list_records
Gets paginated records, optionally changed after a particular sync count for a dataset and identity. With Amazon Cognito Sync, each identity has access only to its own data. Thus, the credentials used to make this API call need to have access to the identity data. ListRecords can be called with temporary user credentials provided by Cognito Identity or with developer credentials. You should use Cognito Identity credentials to make this API call.
SELECT
count,
dataset_deleted_after_requested_sync_count,
dataset_exists,
dataset_sync_count,
last_modified_by,
merged_dataset_names,
next_token,
records,
sync_session_token
FROM aws.cognito_sync.records
WHERE identity_pool_id = '{{ identity_pool_id }}' -- required
AND identity_id = '{{ identity_id }}' -- required
AND dataset_name = '{{ dataset_name }}' -- required
AND region = '{{ region }}' -- required
AND lastSyncCount = '{{ lastSyncCount }}'
AND nextToken = '{{ nextToken }}'
AND maxResults = '{{ maxResults }}'
AND syncSessionToken = '{{ syncSessionToken }}'
;
UPDATE examples
- update_records
Posts updates to records and adds and deletes records for a dataset and user. The sync count in the record patch is your last known sync count for that record. The server will reject an UpdateRecords request with a ResourceConflictException if you try to patch a record with a new value but a stale sync count. For example, if the sync count on the server is 5 for a key called highScore and you try and submit a new highScore with sync count of 4, the request will be rejected. To obtain the current sync count for a record, call ListRecords. On a successful update of the record, the response returns the new sync count for that record. You should present that sync count the next time you try to update that same record. When the record does not exist, specify the sync count as 0. This API can be called with temporary user credentials provided by Cognito Identity or with developer credentials.
UPDATE aws.cognito_sync.records
SET
DeviceId = '{{ DeviceId }}',
RecordPatches = '{{ RecordPatches }}',
SyncSessionToken = '{{ SyncSessionToken }}'
WHERE
identity_pool_id = '{{ identity_pool_id }}' --required
AND identity_id = '{{ identity_id }}' --required
AND dataset_name = '{{ dataset_name }}' --required
AND region = '{{ region }}' --required
AND SyncSessionToken = '{{ SyncSessionToken }}' --required
AND `x-amz-Client-Context` = '{{ x-amz-Client-Context}}'
RETURNING
records;