问题描述
我正在尝试遵循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 (将#修改为@)