Node.js DynamoDB callback
Can't speak to how it'll scale, but for your 2nd question: Yes, the code above is asynchronous.

When you call db.query() or server.get() you pass a callback as the 2nd argument. That's the asynchronous stuff, as you don't know when that callback will be invoked.

You basically just say "call me when it's done" and continue about your business (i.e. in the case of db.query() the evaluation will proceed to return next(); without "waiting" for the query to finish).

If it were synchronous, it'd be something like result = db.query(params); where everything would wait for the query to return something to assign to result.

By the way (so this is actually a review and not just an explanation)


fix your indentation
in JS it's better to not use the brace-on-new-line style
you're missing some semi-colons
you don't need to quote all those property names in the params object
beware of using undefined, since that isn't actually a keyword. Some runtimes let you say undefined = 23 in which case undefined is then just another (defined) variable. Use null instead