background preloader

Databases & node.js

Facebook Twitter

Redis. Node.js and Redis Pub-Sub. Static Version This is the 7th in a series of posts leading up to Node.js Knockout on how to use node.js. This post, cross-posted from GitHub, was written by James Bracy, founder of Redis To Go. Redis To Go is a dead simple solution for managed Redis instances. Node.js and Redis Pub-Sub Node.js is a perfect platform for creating event driven applications. Redis and WebSockets are great companions to Node.js. Dependencies Node.js, Redis, and a WebSocket enabled browser (Firefox 4, Google Chrome 4, or Safari 5) are required. The easiest way to get a Redis instance would be to use Redis To Go.

. $ git clone cd redis/src$ make$ sudo make install$ cd ../..$ rm -rf redis Now you can start a Redis instance locally using the redis-server command. Create the Project Create a directory for the project. . $ mkdir flight-stream$ cd flight-stream Create the Server Initially the Node.js server will simply server the static index.html file that will be create. Server.js. Node + Redis = Fun. Static Version node brings asynchronous, evented I/O to the server.

Redis gives you a blazing fast database with support for strings, lists and sets. Both Redis and Node.js follow certain patterns, Redis for data-storage, and node for event based programming. I hope to give an introduction to both in this article. By the time we are done, we will have built a Pastebin service. Getting Started I will assume that the reader is comfortable with Javascript, including using events and passing around functions. Before we get down to the code, here is the software you will need: node ( we will use v0.2.0 )Redisredis-node-client - to connect to Redis from node. Finally, here is how our code is organized. snip|- deps/ |- redis-node-client/ |- nerve/ |- underscore.js|- run|- snip.js A note on the node module system Node modules are used by importing them into the current scope using require(). Node <script> to test our application, we will be using this shell script, so that we can directly do #!

Node "$@" MongoDB. Node.js and MongoDB. Static Version This was the sixth in a series of posts leading up to Node.js Knockout on how to use node.js. This post was written by 10gen and is cross-posted from their blog. 10gen is the corporate sponsor of MongoDB. MongoDB bridges the gap between key-value stores (which are fast and highly scalable) and traditional RDBMS systems (which provide rich queries and deep functionality). Node and MongoDB Node.js is turning out to be a framework of choice for building real-time applications of all kinds, from analytics systems to chat servers to location-based tracking services.

The rationale is certainly there. Node.js MongodB Driver Especially impressive to us at 10gen has been the community support for Node.js and MongoDB. Hummingbird Need a real-world example? Mongoose Of course, one of the admitted difficulties in working with Node.js is dealing with deep callback structures. View the discussion thread. Blog rolling with mongoDB, express and Node.js. Static Version Article and Code updated by loarabia (Larry Olson). Article and Code updated by Toby Clemson In this article I hope to take you through the steps required to get a fully-functional (albeit feature-light) persistent blogging system running on top of node.

The technology stack that we'll be using will be node + express + mongoDB all of which are exciting, fast and highly scalable. You'll also get to use jade and stylus for driving the templated views and styling! We will be using npm to ease the package management and installation issues. This article will be fairly in-depth so you may want to get yourself a rather large mug of whatever beverage you prefer before you settle down :) Getting Started / Pre-Requisites. mongoDB Installation is as simple as downloading the installer from here.

Node.js I'll assume that you already have an installed version of node.js (why else would you be looking at a how-to?! Npm npm search Getting hold of express Defining our application The data types !!!