Skip to content

v0.2.0

Compare
Choose a tag to compare
@snurra snurra released this 10 Mar 14:13
· 4 commits to master since this release

Foreign key conversion will now only happen automatically when a model is created or on a reset. In other instances the conversion has to be explicitly requested by using the useForeignKeys set option.

This change makes it possible to change the value of a property which is set up to use a foreign key.

Example:

var MyStrictModel = Backbone.StrictModel.extend({
  props: {
    "name": {
      "type": Backbone.StrictModel.type.STRING,
      "foreignKey": "firstName"
    }
  }
});

In the example above, doing new MyStrictModel({ firstName: "Göran" }) will result in a model with { "name": "Göran" }. However, when just setting properties, you will need to be explicit about wanting to use the foreign mappings. For example, myModelInstance.set({ firstName: "Sven" }) will have no effect on the model instance, but myModelInstance.set({ firstName: "Sven" }, { useForeignKeys: true }) will.