O'Reilly logo

CoffeeScript Application Development by Ian Young

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required