Skip to main content

records

Creates, updates, deletes, gets or lists a records resource.

Overview

Namerecords
TypeResource
Idaws.cognito_sync.records

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
countintegerTotal number of records.
dataset_deleted_after_requested_sync_countbooleanA boolean value specifying whether to delete the dataset locally.
dataset_existsbooleanIndicates whether the dataset exists.
dataset_sync_countinteger (int64)Server sync count for this dataset.
last_modified_bystringThe user/device that made the last change to this record.
merged_dataset_namesarrayNames of merged datasets.
next_tokenstringA pagination token for obtaining the next page of results.
recordsarrayA list of all records.
sync_session_tokenstringA token containing a session ID, identity ID, and expiration.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
list_recordsselectidentity_pool_id, identity_id, dataset_name, regionlastSyncCount, nextToken, maxResults, syncSessionTokenGets 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_recordsupdateidentity_pool_id, identity_id, dataset_name, region, SyncSessionTokenx-amz-Client-ContextPosts 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.

NameDatatypeDescription
dataset_namestringA string of up to 128 characters. Allowed characters are a-z, A-Z, 0-9, '_' (underscore), '-' (dash), and '.' (dot).
identity_idstringA 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_idstringA name-spaced GUID (for example, us-east-1:23EC4050-6AEA-7089-A2DD-08002EXAMPLE) created by Amazon Cognito. GUID generation is unique within a region.
regionstringAWS region (default: us-east-1)
lastSyncCountinteger (int64)The last server sync count for this record.
maxResultsintegerThe maximum number of results to be returned.
nextTokenstringA pagination token for obtaining the next page of results.
syncSessionTokenstringA token containing a session ID, identity ID, and expiration.
x-amz-Client-ContextstringIntended to supply a device ID that will populate the lastModifiedBy field referenced in other methods. The ClientContext field is not yet implemented.

SELECT examples

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

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;