dynamodb-geo.js
dynamodb-geo.js copied to clipboard
What are the requirements on the table structure, and how does it all tie together?
Currently, the documentation uses a naming convention that's really uninformative - for example, the default hash and range keys are simply called hashKey
and rangeKey
. Yet, I can't change them however I want, without breaking stuff (it seems like, anyway...).
It would be nice with some documentation about how this library uses the table key schema and indexes. Which parts are calculated based on the geohash? What do I need to provide? That would also help with setting up the table structure in CloudFormation, rather than at runtime.
Sorry if this isn't clear. The default naming convention is lifted from the parent Java implementation, but every attribute name can be customised by setting public properties of your GeoDataManagerConfiguration
instance before you pass it to a GeoTableManager
or GeoTableUtil
eg by setting config.hashKeyAttributeName = "myHashKey"
, see https://github.com/rh389/dynamodb-geo.js#configuration-reference.
I'm aware that the API style is a bit non-canonical for javascript. AWS's official node SDK is very java-like and I've tried to keep to their style so hopefully it isn't jarring against the rest of your DynamoDB code.
The easiest way currently to see the expected schema for a given configuration is to have GeoTableUtil
prepare a CreateTableInput
object for you - if you log out the CreateTableInput
object you'll see what the schema this library expects.
As for how it all ties together - it's basically just an abstraction layer to allow you to work using coordinate pairs, whereas the underlying queries and writes use S2 hashes. If you're comfortable with what S2 hashes are and how they work, you might prefer to ditch the middle man and use them directly. If you have specific questions I'll do my best to clarify.
I guess what I'm trying to ask is this: given that I'm new to everything about DynamoDB and everything about geo-hashing, and I want to understand how this library works, I can read up on DynamoDB from the AWS docs, and on S2 e.g. here. However, there are still some things that I can't learn from reading up on the underlying concepts, namely how they're implemented by DocumentDB-Geo. (Arguably, those things should have been documented already in the Java library, but since I'm using this and not that it felt more natural to ask here...)
The things I want to know are more like "given this table structure and this data point, where does this library put the coordinate hash?" and "what does it expect me to provide more than coordinates?" Also, maybe, "what parts of the examples in the Readme are using a naming convention in the library, and what parts are just dummy names?"
I think it might go a long way to update the examples in the readme to be a more concrete example, but it would also be interesting (to me, but maybe not to enough people to actually be worth the time to write it...) to get a better understanding of the specific inner workings of dynamodb-geo.