require table schema #13

jed opened this Issue Apr 27, 2012 · 3 comments


None yet
2 participants

jed commented Apr 27, 2012

currently, tables are specified by name only, and the schema is inferred at query time.

it would probably be better to avoid issues like #9 by making table schemas mandatory, so that queries that violate the schema fail before execution.


mhart commented Apr 27, 2012

You're just talking about needing to specify which is the HashKey and RangeKey, correct? Not talking about requiring a more comprehensive schema of the other attributes in the table... As that would certainly impact the flexibility of the library, no?


jed commented Apr 27, 2012

correct. right now i'm inferring hash/range by insertion order per request. would be much better to encourage reusable tables defined at setup.


mhart commented Apr 27, 2012

True, although if that becomes the only option then there's the potential then that ppl will need to either specify the schema with each query, eg:

db.get("myTable", {hash: 'id', range: 'date'})
  .query({id: "123", date: {">=": new Date - 6000 }})
  .get(["id", "date", "name"])
  .fetch(function(err, data){ ... })

Or, they'll need to construct and pass their table objects around everywhere, instead of just a single db.

I guess as long as there's still the option to pass an array/list-of-args in, it's a moot point.

db.get("blah").query({id: "123"}, {date: {">=": new Date - 6000 }})
// or just
db.get("blah").query('123', {">=": new Date - 6000 }) // id, date

@jed jed closed this Mar 6, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment