Skip to Main Content
Node for Front-End Developers
book

Node for Front-End Developers

by Garann Means
January 2012
Beginner content levelBeginner
60 pages
1h 18m
English
O'Reilly Media, Inc.
Content preview from Node for Front-End Developers

Chapter 5. Data Sources and Flow Control

Up until now, the client has been able to get whatever it needs more or less immediately. We wait for our end user to initiate a request, but that user never waits for the application. Of course, that isn’t how real web applications work. Dynamic data requires some sort of data storage, and working with a data store takes time. When our user initiates a request to the server, the application on the server may, in turn, need to initiate its own request to a database, and will not be able to respond to the user until a response comes from the data source. While connecting to a database is a necessary function in itself, it’s also a good place to discuss server-side flow control.

Connecting to a Database

If you have some experience dealing with databases in other server frameworks, thinking about the way it’s done in Node can be a bit tricky. Firstly, Node has no default way of connecting to a database. Depending on your experience, you may have worked with ODBC or JDBC (Open Database Connectivity and Java Database Connectivity, respectively). No analogue to those things exists in Node. A database will provide its own API and you will connect directly to that. The only thing shared between Node itself and the database will be the EventEmitter vocabulary, if that.

The second trick is that there are a lot of different ways people choose to store data in Node. If you’re used to .NET on the back-end, you probably expect to use SQL Server. If you’ve ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Professional Website Performance: Optimizing the Front-End and Back-End

Professional Website Performance: Optimizing the Front-End and Back-End

Peter Smith
Redux Quick Start Guide

Redux Quick Start Guide

James Lee, Tao Wei, Suresh Kumar Mukhiya

Publisher Resources

ISBN: 9781449329112Errata PageSupplemental Content