DynamoDB 删除 table 完成状态
DynamoDB delete table complete status
我正在使用以下 Javascript 在 Node.
中删除 DynamoDB 中的 table
var params = {
TableName : "MyTable"
};
dynamodb.deleteTable(params, function(err, data) {
// Not really done yet...!
});
我需要知道 table 何时真正被删除。回调并没有指明这一点,因为它在调用时仍在删除过程中。有没有办法知道删除何时完成?
waitFor
API 可用于检查 table 是否存在。
Waits for the tableNotExists state by periodically calling the
underlying DynamoDB.describeTable() operation every 20 seconds (at
most 25 times).
删除 table 并使用 waitFor API 检查 table 是否存在的示例代码:-
var AWS = require("aws-sdk");
AWS.config.update({
region : "us-west-2",
endpoint : "http://localhost:8000"
});
var dynamodb = new AWS.DynamoDB();
var params = {
TableName : "country"
};
var paramsWaitFor = {
TableName : 'country' /* required */
};
function waitForTableNotExists() {
dynamodb.waitFor('tableNotExists', paramsWaitFor, function(waitForErr,
waitForData) {
if (waitForErr) {
console.log(waitForErr, waitForErr.stack); // an error occurred
} else {
console.log('Deleted ====>', JSON.stringify(waitForData, null, 2));
}
});
}
dynamodb.deleteTable(params, function(err, data) {
if (err) {
console.error("Unable to delete table. Error JSON:", JSON.stringify(
err, null, 2));
} else {
console.log("Deleted table. Table description JSON:", JSON.stringify(
data, null, 2));
waitForTableNotExists();
}
});
我正在使用以下 Javascript 在 Node.
中删除 DynamoDB 中的 tablevar params = {
TableName : "MyTable"
};
dynamodb.deleteTable(params, function(err, data) {
// Not really done yet...!
});
我需要知道 table 何时真正被删除。回调并没有指明这一点,因为它在调用时仍在删除过程中。有没有办法知道删除何时完成?
waitFor
API 可用于检查 table 是否存在。
Waits for the tableNotExists state by periodically calling the underlying DynamoDB.describeTable() operation every 20 seconds (at most 25 times).
删除 table 并使用 waitFor API 检查 table 是否存在的示例代码:-
var AWS = require("aws-sdk");
AWS.config.update({
region : "us-west-2",
endpoint : "http://localhost:8000"
});
var dynamodb = new AWS.DynamoDB();
var params = {
TableName : "country"
};
var paramsWaitFor = {
TableName : 'country' /* required */
};
function waitForTableNotExists() {
dynamodb.waitFor('tableNotExists', paramsWaitFor, function(waitForErr,
waitForData) {
if (waitForErr) {
console.log(waitForErr, waitForErr.stack); // an error occurred
} else {
console.log('Deleted ====>', JSON.stringify(waitForData, null, 2));
}
});
}
dynamodb.deleteTable(params, function(err, data) {
if (err) {
console.error("Unable to delete table. Error JSON:", JSON.stringify(
err, null, 2));
} else {
console.log("Deleted table. Table description JSON:", JSON.stringify(
data, null, 2));
waitForTableNotExists();
}
});