DailyJS

Son, Sequelize

Alex R. Young

Subscribe

@dailyjs

Facebook

Google+

libraries templating databases

Son, Sequelize

Posted by Alex R. Young on .
Featured

libraries templating databases

Son, Sequelize

Posted by Alex R. Young on .

Sequelize

Sequelize by Sascha Depold is an ORM for Node and MySQL. It can be installed with npm install sequelize.
Creating mappings to tables is straightforward:

var Project = sequelize.define('Project', {
  title: Sequelize.STRING,
  description: Sequelize.TEXT
})

After defining these structures, Sequelize can create suitable tables:

Project.sync(function(table, error) {
})

This library also supports associations:

Project.hasMany('tasks', Task, 'projects')

And finders with a familiar API:

Project.find(1, function(project) {
})

I like the look of the chainQueries method, which is a
query chaining helper.

Son

Son by Tim Farland converts JSON to CSS -- it's a little bit like Sass but designed
to be more JavaScript-native. This example is provided in the README:

(function(){
  var myColour = '#ff0000';
  var styles = {
    "#navbar": {
      width: "80%",
      height: "23px",
      ul: {
        list: {
          "style-type":  "none"
         }
      },
      li: {
          "float": "left",
          border: "1px solid " + myColour,
          padding: "10px",
          a: {
              "font-weight": "bold",
              color: myColour
          }
      }
  };

  return styles;
})();

As well as variable support, it also has a mixin helper. The author has
written up a list of gotchas and ideas for future features, so it seems
like he's using it actively.