Weaselpecker: Node.js- Waterline Simple Mocking Library

Weaselpecker is a small nodejs module I wrote for mocking Waterline models. His name is inspired in the famous and beloved weasel woodpecker rider.

alt WeaselPecker

About Waterline

Waterline is a brand new kind of storage and retrieval engine.

It provides a uniform API for accessing stuff from different kinds of databases, protocols, and 3rd party APIs. That means you write the same code to get and store things >like users, whether they live in Redis, mySQL, LDAP, MongoDB, or Postgres.

(Waterline Github repository)


Waterline is an ORM, good examples of known ORM’s are mongoose for nodejs and Hibernate (for Java).

A good thing about Waterline is that you can implement custom “Adapters”. Adapters provide an interface for connecting to different data stores. You can implement your own adapter for your favorite database if it doesn’t exists or if an existing adapter doesn’t fit to your needs. You can also contribute to your favorite existing database adapter :). At the time of this post there are adapters for PostgreSQl, MySQL, MongoDB, Memory, Disks, Twitter, Neo4j among others.

Weaselpecker Quick Example

var weaselpecker = require('weaselpecker');
// Create a model mock instance
var ModelMock = weaselpecker.mock();
// Set results for find method
ModelMock.setResults('find', [
  [{name: 'pecker'}]

         .exec(function(err, results){
           console.log(results); // [{name: 'pecker'}]

Find out more in the github repository https://github.com/ottogiron/weaselpecker

comments powered by Disqus