Book Image

CoffeeScript Application Development

By : Ian Greenleaf Young
Book Image

CoffeeScript Application Development

By: Ian Greenleaf Young

Overview of this book

JavaScript is becoming one of the key languages in web development. It is now more important than ever across a growing list of platforms. CoffeeScript puts the fun back into JavaScript programming with elegant syntax and powerful features. CoffeeScript Application Development will give you an in-depth look at the CoffeeScript language, all while building a working web application. Along the way, you'll see all the great features CoffeeScript has to offer, and learn how to use them to deal with real problems like sprawling codebases, incomplete data, and asynchronous web requests. Through the course of this book you will learn the CoffeeScript syntax and see it demonstrated with simple examples. As you go, you'll put your new skills into practice by building a web application, piece by piece. You'll start with standard language features such as loops, functions, and string manipulation. Then, we'll delve into advanced features like classes and inheritance. Learn advanced idioms to deal with common occurrences like external web requests, and hone your technique for development tasks like debugging and refactoring. CoffeeScript Application Development will teach you not only how to write CoffeeScript, but also how to build solid applications that run smoothly and are a pleasure to maintain.
Table of Contents (19 chapters)
CoffeeScript Application Development
About the Author
About the Reviewers

Using a database

We've successfully moved our application's data to an encapsulated endpoint, which is great. Now that we've done that, we can start thinking about making that data dynamic. Right now it's stored in a static code file. This is fine when none of the data needs to change, but if we want our application to be interactive, we'll need a way to work with the data. It's time to use a database.

There are many powerful database solutions available, from SQL options such as MySQL and Postgres, to a newer breed of NoSQL engines such as MongoDB and CouchDB, plus simple key-value stores such as Redis and Riak. Almost all popular database engines have drivers available for Node. However, we're going to use a simpler option. We'll be using a database named nStore, which is written entirely in JavaScript and uses a simple file store. This means we won't need to fuss with installing extra software, running services, and compiling drivers. Instead, we can install a simple Node module and focus...