Storing and retrieving data with Mongoskin

Mongoskin is a convenience library providing a high-level interface for mongodb without blocking access to the existing mongodb methods.

For this recipe, we'll re-implement the quotes database in MongoDB using Mongoskin.

Getting ready

We'll need the mongoskin module.

npm install mongoskin

We can also create a new folder, with a new quotes.js file.

How to do it...

We'll require mongoskin and use it to make a client and a collection instance. We don't need to create a server instance, nor manually open the client as in the former recipe, mongoskin takes care of that.

var mongo = require('mongoskin'); var client = mongo.db('localhost:27017/quotes'); var collection = client.collection('quotes'); var params = {author: ...

Get Node Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.