Mastering Web Application

(Rick Simeone) #1

Building and Testing


All the elements of the stack and tools described in this book are
JavaScript-based, free to use, open source projects.

Persistence store


When it comes to data storage there are many options to choose from and the recent
NoSQL movement only multiplied a number of alternatives. For the purpose of this
book we are going to use the document-oriented MongoDB database as it fits well
into the JavaScript-oriented environment:



  • Documents are stored using the JSON-style data format (Binary JSON -
    BSON in short).

  • Querying and manipulating data can be done using JavaScript and the
    familiar JSON syntax.

  • It is possible to expose data as REST endpoints serving and consuming data
    in the JSON format.


No prior knowledge of MongoDB is needed to follow the examples in this book, and
we will try to explain tricky bits while discussing code snippets. By no means are we
suggesting that MongoDB or document-oriented, NoSQL databases are a better fit
for AngularJS applications. AngularJS is back-end and storage-agnostic.


MongoLab

MongoDB is relatively easy to start with, and most of JavaScript developers will feel
at home while working with this document-oriented database. To makes things even
easier our sample application relies on the hosted version of the MongoDB. As a
result, no software installation is necessary to run examples from this book.


There are multiple cloud-based hosting options available for MongoDB, but we've
found that MongoLab (https://mongolab.com) is reliable, easy to start with and
offers free hosting for databases of size below 0.5 GB. The free storage space offered
by MongoLab is more than enough to play with the examples from this book.


MongoLab has one more, non-negligible advantage; it exposes hosted databases
through a very well-designed REST interface. We are going to rely on this interface
to demonstrate how AngularJS can talk to REST endpoints.


The online registration is necessary to start using MongoLab, but it is a fairly painless
process that boils down to filling in a short, electronic form. As soon as this is done,
we can enjoy access to a hosted MongoDB database, the REST interface speaking
JSON, and the online administration console.

Free download pdf