v0.2.0-beta.9

@samselikoff samselikoff released this May 13, 2016 · 104 commits to master since this release

This release contains some breaking changes from 0.2.0-beta.8.

Update notes:

  • Schema model classes are now pluralized. They used to be singularized, taking after Rails' conventions, but I think it's better to match our db conventions (e.g. db.users).

    So you'll need to change

    schema.user.all()
    schema.user.find(1)

    to

    schema.users.all()
    schema.users.find(1)

    and so on. The upgrade should be a relatively straightforward.

  • Breaking changes on ORM/Collection:

    • There's now a .models property on Collections, which gives you access to the underlying JavaScript array. This should be used if you want to munge the collection using Lodash, Ramda et al.

      let usersCollection = schema.users.all();
      let uniqueUsers = _.uniq(usersCollection.models, u => u.firstName);
    • Collection no longer attempts to mimic an array. This turned out to be confusing, since you can't really subclass arrays in JavaScript, and it would sometimes be compatible with functions that operate on arrays, but sometimes not.

      So, you can no longer use the array accessor on a collection, meaning the following won't work:

      let authors = schema.authors.all();
      
      // The following no longer work
      authors[1];
      authors.length;
      authors.push(model);
      authors.map(f);
      authors.forEach(f);
      authors.reduce(f);
      authors.toArray(); // use authors.models instead

      Instead, if you need to use array-methods on Collections, access the .models property. You can always convert your transformed array back to a Collection, for example to tell Mirage to serialize your response:

      import { Collection } from 'ember-cli-mirage';
      
      let authors = schema.authors.all().models;
      let topPosts = authors.map(a => a.topPost);
      
      return new Collection('post', topPosts);

Changes:

Downloads