我有点新的Node.js和受回调异步。 能否请你让我知道,如果这是有一个异步调用的正确方法?
function myFunc(schema) {
async.each(Object.keys(schema), function(variable) {
for (item in schema[variable]) {
for (field in schema[variable][item]) {
// Some operations go here
}
createDB(item, schema[variable][item]);
}
});
}
function CreateDB(name, new_items) {
ddb.createTable(selected_field.name, {hash: ['id', ddb.schemaTypes().number],
range: ['time', ddb.schemaTypes().string],
AttributeDefinitions: new_items
},
{read: 1, write: 1}, function(err, details) {
console.log("The DB is now created!");
});
}
谢谢