Making our application interactive

We've improved our application to be fed data from a database. Now it's time for the payoff—we can let users interact with our application, and their actions can be reflected in our data. We're going to add a feature where customers may buy a pet they like, directly through the website! We've got some implementation work to do.

To send a request to buy a pet, we'll need the pet ID that's used as the database key. This is returned when we query all the records, but so far we've been dropping it from the results we send to the browser. We'll update the data in routes/pets.coffee:

exports.list = (req, res) -> nStore.new 'data/pets.db', (err, petsDB) -> return _fail err, res if err? petsDB.all (err, result) -> return ...

Get CoffeeScript Application Development now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.