I attended the Amsterdam Node Meetup last Thursday. There were three short talks and I figured I’d jot down some notes on each of them.
Marionette.js – Justin Halsall
Backbone is nice, but not very DRY. It is not very opinionated, and you end up reinventing the wheel. Marionette is a framework on top of Backbone that does have opinions.
It comes with a bunch of default events that you can hook into. There are a bunch of components, so you can use just the things you need. It is much more DRY than Backbone.
Views for instance are split up into ItemViews, CollectionViews, CompositeViews, and Layouts. Each of these have a bunch of built in best practices, like a ui field, which is an object that you can use to define ui components.
Single object subschemas in Mongoose – James Bryan Graves
Working with single object relations is tricky with Mongoose. If you don’t have it in your schema at all, nothing happens. If you add it as a mixed type, you have to explicitly set it as modified. You can set a schema for an array-relation, but not for a single model relation.
He put together a method that allows you to define a subschema for a single model. This way it does what you expect it to do when you embed one model in another. Mongoose still represents it as an array internally. It is a really useful technique to add a thin sub-object to your object, if you just need a couple fields. The canonical example being a user object that is stored somewhere, and you add just his name to a comment he made.
AWS and DynamoDB – Dominiek ter Heide
The final talk was about measuring the maturity of Node by way of seeing how easy it is to do certain things. For instance interfacing with Amazon S3 and DynamoDB. Well, turns out is very easy with the following modules:
knox – A library for easily storing files in S3
proxyquire – A module for easily creating stubs of modules required by another module
aws – Amazon supported interface with AWS. It can be used to store stuff in DynamoDB. You need to convert your objects to Amazon’s weird format.