NIKHIL C M
NIKHIL C M

Reputation: 4236

Transactions in AWS Document DB

How well is documentDB compared to dynamo DB, considering transactions capability ?

Following is an example of transaction operation done using dynamoDB.

const transactionResponse = await docClient.transactWrite({
            TransactItems: [
                {
                    Put: {
                        TableName: Table1,
                        Item: {
                            id,
                            userId,
                            anotherID,
                            createdAt: (new Date()).toISOString()
                        }
                    }
                },
                {
                    Update: {
                        TableName: Table2,
                        Key: {anotherID},
                        UpdateExpression: `set available = available - :val, count = count + :val, lastUpdatedDate = :updatedAt`,
                        ExpressionAttributeValues: {
                            ":val": 1,
                            ":updatedAt": (new Date()).toISOString(),
                        }
                    }
                }
            ]

        }).promise();

Is it possible to do the same logic with DocumentDB ? I have found that, it is not possible to do multi statement transaction in AWS documentDB.

Upvotes: 2

Views: 592

Answers (1)

Shachaf.Gortler
Shachaf.Gortler

Reputation: 5745

DocumentDB does not support transactions , transactions were introduced to mongoDB in version 4.0 . DocumentDB only supports mongo version 3.6.

Atals in the mongo version in the cloud , https://www.mongodb.com/cloud/atlas.

that supports the newer versions of mongo that do have transactions.

Upvotes: 2

Related Questions