ApsaraDB for MongoDB supports the DynamoDB protocol. This topic describes the compatibility details of DynamoDB-compatible ApsaraDB for MongoDB instances.

Background information

Amazon DynamoDB is a fully managed NoSQL database service that provides fast and predictable performance with seamless scalability. ApsaraDB for MongoDB is compatible with the DynamoDB protocol. You can select the DynamoDB protocol to create a DynamoDB-compatible ApsaraDB for MongoDB instance. For more information about how to create a DynamoDB-compatible instance, see Create a DynamoDB-compatible ApsaraDB for MongoDB instance.

Precautions

  • The DynamoDB protocol is supported only for ApsaraDB for MongoDB sharded cluster instances that run MongoDB 4.0.
  • You can modify the protocol type to DynamoDB for existing ApsaraDB for MongoDB sharded cluster instances to make them compatible with the DynamoDB protocol.
  • The DynamoDB protocol is supported only for ApsaraDB for MongoDB sharded cluster instances that use the VPC network type. No authentication is required.

Compatibility details of DynamoDB operations

OperationParameterSupportedDescription
CreateTableRequest parametersRequired parameter: AttributeDefinitionsYesN/A
Required parameter: KeySchemaYesN/A
Required parameter: TableNameYes
  • It cannot contain the following special characters: dollar sign ($).
  • It cannot start with the system. prefix.
  • It must be 1 to 100 characters in length.
Optional parameter: BillingModeNoN/A
Optional parameter: GlobalSecondaryIndexesYesN/A
Optional parameter: LocalSecondaryIndexesYesN/A
Optional parameter: ProvisionedThroughputNoN/A
Optional parameter: SSESpecificationNoN/A
Optional parameter: StreamSpecificationYesThe StreamViewType parameter supports only the following values:
  • KEYS_ONLY
    Note KEYS_ONLY supports only partition keys, but does not support sort keys.
  • NEW_IMAGE
Optional parameter: TagsNoN/A
Response parametersTableDescriptionYesN/A
UpdateTableRequest parametersOptional parameter: AttributeDefinitionsYesN/A
Optional parameter: BillingModeNoN/A
Required parameter: GlobalSecondaryIndexesUpdatesYesCREATE and DELETE are supported. UPDATE is not supported.
Optional parameter: ProvisionedThroughputNoN/A
Optional parameter: ReplicaUpdatesNoN/A
Optional parameter: SSESpecificationNoN/A
Optional parameter: StreamSpecificationYesThe StreamViewType parameter supports only the following values:
  • KEYS_ONLY
    Note KEYS_ONLY supports only partition keys, but does not support sort keys.
  • NEW_IMAGE
Required parameter: TableNameYesN/A
Response parametersTableDescriptionYesFor more information, see TableDescription.
DescribeTableRequest parametersRequired parameter: TableNameYesN/A
Response parametersTableYesFor more information, see TableDescription.
ListTablesRequest parametersOptional parameter: ExclusiveStartTableNameNoRecords in different pages are not supported. No limit is imposed on the number of returned records.
Optional parameter: LimitNoRecords in different pages are not supported. No limit is imposed on the number of returned records.
Response parametersLastEvaluatedTableNameNoN/A
TableNamesYesN/A
DeleteTableRequest parametersRequired parameter: TableNameYesN/A
Response parametersTableDescriptionYesFor more information, see TableDescription.
PutItemRequest parametersRequired parameter: ItemYesN/A
Required parameter: TableNameYesN/A
Optional parameter: ConditionalOperatorNoN/A
Optional parameter: ConditionExpressionYesFor more information, see Compatibility details of expressions.
Optional parameter: ExpectedNoN/A
Optional parameter: ExpressionAttributeNamesYesFor more information, see Compatibility details of expressions.
Optional parameter: ExpressionAttributeValuesYesFor more information, see Compatibility details of expressions.
Optional parameter: ReturnConsumedCapacityNoN/A
Optional parameter: ReturnItemCollectionMetricsNoN/A
Optional parameter: ReturnValuesYesN/A
Response parametersAttributesYesN/A
ConsumedCapacityNoN/A
ItemCollectionMetricsNoN/A
UpdateItemRequest parametersRequired parameter: KeyYesN/A
Required parameter: TableNameYesN/A
Optional parameter: AttributeUpdatesNoN/A
Optional parameter: ConditionalOperatorNoN/A
Optional parameter: ConditionExpressionYesFor more information, see Compatibility details of expressions.
Optional parameter: ExpectedNoN/A
Optional parameter: ExpressionAttributeNamesYesFor more information, see Compatibility details of expressions.
Optional parameter: ExpressionAttributeValuesYesFor more information, see Compatibility details of expressions.
Optional parameter: ReturnConsumedCapacityNoN/A
Optional parameter: ReturnItemCollectionMetricsNoN/A
Optional parameter: ReturnValuesYesN/A
Optional parameter: UpdateExpressionYesFor more information, see Compatibility details of expressions.
Response parametersAttributesYesN/A
ConsumedCapacityNoN/A
ItemCollectionMetricsNoN/A
GetItemRequest parametersRequired parameter: KeyYesN/A
Required parameter: TableNameYesN/A
Optional parameter: AttributesToGetNoN/A
Optional parameter: ConsistentReadNoN/A
Optional parameter: ExpressionAttributeNamesYesFor more information, see Compatibility details of expressions.
Optional parameter: ProjectionExpressionYesFor more information, see Compatibility details of expressions.
Optional parameter: ReturnConsumedCapacityNoN/A
Response parametersConsumedCapacityNoN/A
ItemYesN/A
DeleteItemRequest parametersRequired parameter: KeyYesN/A
Required parameter: TableNameYesN/A
Optional parameter: ConditionalOperatorNoN/A
Optional parameter: ConditionExpressionYesFor more information, see Compatibility details of expressions.
Optional parameter: ExpectedNoN/A
Optional parameter: ExpressionAttributeNamesYesFor more information, see Compatibility details of expressions.
Optional parameter: ExpressionAttributeValuesYesFor more information, see Compatibility details of expressions.
Optional parameter: ReturnConsumedCapacityNoN/A
Optional parameter: ReturnItemCollectionMetricsNoN/A
Optional parameter: ReturnValuesYesN/A
Response parametersAttributesYesN/A
ConsumedCapacityNoN/A
ItemCollectionMetricsNoN/A
BatchWriteItemRequest parametersRequired parameter: RequestItemsYesN/A
Optional parameter: ReturnConsumedCapacityNoN/A
Optional parameter: ReturnItemCollectionMetricsNoN/A
Response parametersConsumedCapacityNoN/A
ItemCollectionMetricsNoN/A
UnprocessedItemsYesN/A
BatchGetItemRequest parametersRequired parameter: RequestItemsYesItem does not support AttributesToGet and ConsistentRead parameters.
Optional parameter: ReturnConsumedCapacityNoN/A
Response parametersConsumedCapacityNoN/A
ResponsesYesN/A
UnprocessedKeysYesN/A
QueryRequest parametersRequired parameter: TableNameYesN/A
Optional parameter: AttributesToGetNoN/A
Optional parameter: ConditionalOperatorNoN/A
Optional parameter: ConsistentReadNoN/A
Optional parameter: ExclusiveStartKeyYesN/A
Optional parameter: ExpressionAttributeNamesYesFor more information, see Compatibility details of expressions.
Optional parameter: ExpressionAttributeValuesYesFor more information, see Compatibility details of expressions.
Optional parameter: FilterExpressionYesFor more information, see Compatibility details of expressions.
Optional parameter: IndexNameYesN/A
Optional parameter: KeyConditionExpressionYesFor more information, see Compatibility details of expressions.
Optional parameter: KeyConditionsNoN/A
Optional parameter: LimitYesN/A
Optional parameter: ProjectionExpressionYesFor more information, see Compatibility details of expressions.
Optional parameter: QueryFilterNoN/A
Optional parameter: ReturnConsumedCapacityNoN/A
Optional parameter: ScanIndexForwardYesN/A
Optional parameter: SelectNoN/A
Response parametersConsumedCapacityNoN/A
CountYesN/A
ItemsYesN/A
LastEvaluatedKeyYesN/A
ScannedCountYesN/A
ScanRequest parametersRequired parameter: TableNameYesN/A
Optional parameter: AttributesToGetNoN/A
Optional parameter: ConditionalOperatorNoN/A
Optional parameter: ConsistentReadNoN/A
Optional parameter: ExclusiveStartKeyYesN/A
Optional parameter: ExpressionAttributeNamesYesFor more information, see Compatibility details of expressions.
Optional parameter: ExpressionAttributeValuesYesFor more information, see Compatibility details of expressions.
Optional parameter: FilterExpressionYesFor more information, see Compatibility details of expressions.
Optional parameter: IndexNameYesN/A
Optional parameter: LimitYesN/A
Optional parameter: ProjectionExpressionYesFor more information, see Compatibility details of expressions.
Optional parameter: ReturnConsumedCapacityNoN/A
Optional parameter: ScanFilterNoN/A
Optional parameter: SegmentYesN/A
Optional parameter: SelectNoN/A
Optional parameter: TotalSegmentsYesN/A
Response parametersConsumedCapacityNoN/A
CountYesN/A
ItemsYesN/A
LastEvaluatedKeyYesN/A
ScannedCountYesN/A

Compatibility details of DynamoDB Streams operations

OperationParameterSupportedDescription
DescribeStreamRequest parametersRequired parameter: StreamArnYesN/A
Optional parameter: LimitNoN/A
Optional parameter: ExclusiveStartShardIdNoN/A
Response parametersRequired parameter: StreamDescriptionYesThe values of this response parameter of DynamoDB-compatible ApsaraDB for MongoDB instances differ from those of Amazon DynamoDB instances in the following aspects:
  • The value of the StartingSequenceNumber parameter is fixed to unknown.
  • The EndingSequenceNumber parameter indicates a timestamp.
  • The value of the ShardId parameter is fixed to arn:alibaba:mongo-dynamodb@shard-only-1 because a DynamoDB-compatible ApsaraDB for MongoDB sharded cluster instance has only one shard node.
ListStreamsRequest parametersOptional parameter: TableNameYesN/A
Optional parameter: LimitNoN/A
Optional parameter: ExclusiveStartStreamArnNoN/A
Response parametersRequired parameter: StreamsYesFor each table, up to one stream can be returned.
GetShardIteratorRequest parametersRequired parameter: StreamArnYesN/A
Required parameter: ShardIdYesThe value of this parameter is fixed to arn:alibaba:mongo-dynamodb@shard-only-1 because a DynamoDB-compatible ApsaraDB for MongoDB sharded cluster instance has only one shard node.
Required parameter: ShardIteratorTypeYesOnly LATEST and AFTER_SEQUENCE_NUMBER are supported.
Optional parameter: SequenceNumberYesThis parameter is valid only when the ShardIteratorType parameter is set to AFTER_SEQUENCE_NUMBER. The value can be a 32-bit timestamp in seconds.
Response parametersRequired parameter: ShardIteratorYesN/A
GetRecordsRequest parametersRequired parameter: ShardIteratorYesN/A
Optional parameter: LimitYesWhen this parameter is not specified, each page contains 101 data entries, instead of 1 MB of data.
Response parametersRequired parameter: RecordsYesN/A

Data structures of DynamoDB operations

Data typeFieldSupported
TableDescriptionArchivalSummaryNo
AttributeDefinitionsNo
BillingModeSummaryNo
CreationDateTimeNo
GlobalSecondaryIndexesYes
GlobalTableVersionNo
ItemCountYes
KeySchemaYes
LatestStreamArnYes
LatestStreamLabelYes
LocalSecondaryIndexesYes
ProvisionedThroughputNo
ReplicasNo
RestoreSummaryNo
SSEDescriptionNo
StreamSpecificationYes
TableArnNo
TableIdNo
TableNameYes
TableSizeBytesYes
TableStatusYes

Compatibility details of expressions

  • An attribute name that contains .: An attribute name that contains . indicates a scalar attribute or a nested document. In Amazon DynamoDB, if an expression attribute name maps to all elements in a document path, the attribute is handled as a scalar attribute. Otherwise, the attribute is handled as a nested attribute.
    Note Scalar attributes that contain . such as a query or projection expression cannot be processed in ApsaraDB for MongoDB.
  • Projection expressions: support only one-dimensional arrays. When a projection expression contains only one array element, other fields are returned.
  • Condition expressions:
    • Syntax for condition expressions in Amazon DynamoDB:
      condition-expression ::=
            operand comparator operand
          | operand BETWEEN operand AND operand
          | operand IN ( operand (',' operand (, ...) ))
          | function
          | condition AND condition
          | condition OR condition
          | NOT condition
          | ( condition )
      
      comparator ::=
          =
          | <>
          | <
          | <=
          | >
          | >=
      
      function ::=
          attribute_exists (path)
          | attribute_not_exists (path)
          | attribute_type (path, type)
          | begins_with (path, substr)
          | contains (path, operand)
          | size (path)
    • In operand1 comparator operand2, operand1 must be a path and operand2 must be an expression attribute value.
    • In operand1 BETWEEN operand2 AND operand3, operand1 must be a path, and other operand must be expression attribute values.
    • In operand1 IN ( operand2 (',' operand3 (, ...) )), the operand1 must be a path and other operand must be expression attribute values.
    • For the size(path) function in function, the path field must be of the STRING type (used to determine the length) or of the SET or LIST type (used to determine the size). It cannot be of the BINARY or MAP type.
  • Update expressions:
    • Syntax for update expressions in Amazon DynamoDB:
      update-expression ::=
          [ SET action [, action] ... ]
          [ REMOVE action [, action] ...]
          [ ADD action [, action] ... ]
          [ DELETE action [, action] ...]
      
      set-action ::=
          path = value
      
      value ::=
          operand
          | operand '+' operand
          | operand '-' operand
      
      operand ::=
          path | function
      
      function ::=
          if_not_exists (path, value)
          | list_append (list1, list2)
      
      remove-action ::=
          path
      
      add-action ::=
          path value
      
      delete-action ::=
          path value
    • set-action:
      • In SET path = operand, operand cannot be a path.
      • In SET path = operand1 '+'|'-' operand2, operand1 must be a path. This indicates that only field increment or decrement is supported in this expression.
      • In SET path = if_not_exists (path, value), two paths must be equal, and valuemust be an expression attribute value.
      • In SET path = if_not_exists (path, value), partial updates are not supported when multiple conditions are concurrently specified. This indicates that all conditions must be met for this expression to be executed.
      • In SET path = list_append(list1, list2), one of the list1 and list2 values must be equal to path, and the other one must be an expression attribute value.
    • remove-action: When an element in a list is removed, null is used to replace the removed element. The List size remains unchanged and the remaining elements are not shifted.

Data type mappings

Amazon DynamoDB supports differ data types from ApsarsDB for MongoDB. Data type mappings are provided between DynamoDB-compatible ApsaraDB for MongoDB instances and ApsaraDB for MongoDB instances for compatibility between the two sets of data types.

The following table lists the data type mappings.
DynamoDB data typeMongoDB data type
BBinary data
BOOLBoolean
BS*
LArray
MObject
NDouble
NS*
NULLNull
SString
SS*
Note In Amazon DynamoDB, each value must be unique within a binary set (BS), a number set (NS), or a string set (SS). For example, when you insert 1,2,2,3 in an NS, Amazon DynamoDB removes duplicates and then the inserted data becomes 1,2,3. DynamoDB-compatible ApsaraDB for MongoDB instances do not support data deduplication for BSs, NSs, and SSs. In this case, the * data types in the preceding table are processed as arrays. In later release of ApsaraDB for MongoDB, these data types will be optimized for data deduplication.