Mongoose 1.0, Chrome WebGL, it-is

04 Feb 2011 | By Alex Young | Tags testing mongo chrome webgl

Mongoose 1.0

Mongoose 1.0 has been finally released by Guillermo Rauch, Nathan White, and Brian Noguchi. I’ve been watching their 1.0 branch for a while because the API looks improved over the older versions. Incidentally, the older API is what we’ve used for my Nodepad tutorials, so at some point I’ll update Nodepad to Mongoose 1.0.

There’s now a generic Schema class:

var Comments = new Schema({
    title     : String
  , body      : String
  , date      : Date
});

They’ve also added middleware, which is a very interesting feature for reducing nested callbacks. Middleware is defined on the Schema objects like this:

schema.pre('save', function (next) {
    // something goes wrong
    next(new Error('something went wrong'));
});

// later...

myModel.save(function (err) {
  // err can come from a middleware
});

If you want to read more, there’s some nice documentation available for Mongoose on mongoosejs.com.

Chrome WebGL

Until now, Chrome had nascent support for WebGL which was enabled with a command line flag. Version 9 now includes it by default, and Google’s blog post about the update includes a link to some interesting WebGL demos.

it-is

Dominic Tarr said he got tired of typing should all the time, so he made it-is. It’s a very terse assertion library, which supports expressions like these:

it(actual).equal(10)

it({a:1, b: 3})
  .has({
    a: it.typeof('number').notEqual(3)
  , b: it.equal(3)
  })

It looks like Dominic is aiming to support Node with this library, so it might currently be more useful for server-side testing rather than client side. You should be able to get it with: npm install it-is.


blog comments powered by Disqus