ID Optional in latest JazzRecord 0.7

As of version 0.07 build 1236659271 (please find on Github), the ID column is now optional once more when using automigrations or in declaring columns on models. In actuality, allcolumns are optional in model declarations, if manual migrations are used. This is somewhat similar to the Hobo project’s automatically-generated migrations, only in reverse. (model fields are determined by migrations rather than the other way round)

Please note, however, that manual migrations require the explicit inclusion of an ID column:

  var BoxContent = new JazzRecord.Model({
    table: "box_contents",
    belongsTo: {box: boxes}
  });

  JazzRecord.createTable("boxes", {
    id: "int",
    label: "text",
    volume: "float"
  });

  JazzRecord.createTable("box_contents", {
    id: "int",
    name: "text",
    size: "float"
  });

This example shows how a minimal amount of code in the models can set up a 1 to N relationship between a Box and several BoxContent objects. At any time schema operations (like createTable() or removeColumn()) are called, the model’s definition is updated in memory, so calling save() or similar will always be up to date.

Post a Comment

Your email is never shared. Required fields are marked *

*
*