您可以使用AWS SDK for JavaScript中提供的API来获取没有排序键的批量项目。以下是一个示例代码,展示了如何使用AWS AppSync客户端获取这些项目:
const AWS = require('aws-sdk');
const appsync = new AWS.AppSync();
const getItemsWithoutSortKey = async (tableName) => {
const params = {
query: `query GetItemsWithoutSortKey {
itemsWithoutSortKey {
items {
id
name
}
}
}`,
variables: {},
authMode: 'API_KEY'
};
try {
const response = await appsync.graphql(params).promise();
console.log(response.data.itemsWithoutSortKey.items);
} catch (error) {
console.error(error);
}
};
getItemsWithoutSortKey('YourTableName');
在上面的示例代码中,我们使用query
操作来执行GraphQL查询。query
字段的名称可以根据您的需求进行更改。
请将YourTableName
替换为您实际使用的表名。
此外,您需要确保正确配置了AWS SDK并提供了适当的凭证以访问AppSync服务。