Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able to query dynamoDb data using GeoDataManager in Node #42

Open
jerry275 opened this issue Aug 15, 2020 · 1 comment
Open

Not able to query dynamoDb data using GeoDataManager in Node #42

jerry275 opened this issue Aug 15, 2020 · 1 comment

Comments

@jerry275
Copy link

I am trying to follow the very basic tutorial of Geo Library for Amazon DynamoDB given here https://www.npmjs.com/package/dynamodb-geo. Even after following the steps mentioned in link, my myGeoTableManager.queryRadius() call is not giving me any result. Below are the steps that I follow.

I created the dynamoDB table with below script

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!') });

Then I insert and query data in dynamoDB using below script.

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 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);
  });

Even with exactly same latitude and longitude, myGeoTableManager.queryRadius() is giving me empty response.

@muzammal1451415
Copy link

Happening the same to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants