如何解决无法使用Node中的GeoDataManager查询dynamoDb数据
我正在尝试遵循https://www.npmjs.com/package/dynamodb-geo所提供的Amazon DynamoDB地理库非常基本的教程。 即使按照链接中提到的步骤进行操作,我的myGeoTableManager.queryRadius()调用也没有给我任何结果。 以下是我要执行的步骤。
我使用以下脚本创建了dynamoDB表
require("dotenv").config();
var AWS= require('aws-sdk');
AWS.config.update({accessKeyId: process.env.accessKeyId,secretAccessKey: process.env.secretAccessKey,region: "us-east-1"});
const ddb = new AWS.DynamoDB();
const ddbGeo = require('dynamodb-geo');
const config = new ddbGeo.GeoDataManagerConfiguration(ddb,'locationData');
config.hashKeyLength = 5;
const createTableInput = ddbGeo.GeoTableUtil.getCreateTableRequest(config);
// Tweak the schema as desired
createTableInput.ProvisionedThroughput.ReadCapacityUnits = 5;
console.log('Creating table with schema:');
console.dir(createTableInput,{ depth: null });
// Create the table
ddb.createTable(createTableInput).promise()
// Wait for it to become ready
.then(function () { return ddb.waitFor('tableExists',{ TableName: 'locationData' }).promise() })
.then(function () { console.log('Table created and ready!') });
然后,我使用以下脚本在dynamoDB中插入和查询数据。
require("dotenv").config();
var AWS= require('aws-sdk');
AWS.config.update({accessKeyId: process.env.accessKeyId,'locationData');
config.hashKeyLength = 5;
const myGeoTableManager = new ddbGeo.GeoDataManager(config);
myGeoTableManager.putPoint({
RangeKeyValue: { S: '1234' },GeoPoint: {
latitude: 28.749472,longitude: 77.056534
},PutItemInput: {
Item: {
country: { S: 'country1' },capital: { S: 'capital1' }
},}
}).promise()
.then(function() { console.log('Insert Done!') });
myGeoTableManager.putPoint({
RangeKeyValue: { S: '5678' },GeoPoint: {
latitude: 28.749999,longitude: 77.056999
},PutItemInput: {
Item: {
country: { S: 'country2' },capital: { S: 'capital2' }
},}
}).promise()
.then(function() { console.log('Insert Done!') });
myGeoTableManager.queryRadius({
RadiusInMeter: 100000,CenterPoint: {
latitude: 28.749888,longitude: 77.056888
}
}).then((locations) => {
console.log(locations);
});
即使具有完全相同的纬度和经度,myGeoTableManager.queryRadius()也会给我空的响应。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。