Version:

Mirage has an ORM which is managed through its Schema object. Assuming you’ve defined models for your server resources, schema will be passed into your route handlers as the first parameter:

this.get('/authors', (schema, request) => {
  // work with schema
});

From here, you can access registered models, or the database directly.

# schema.db

Returns Mirage’s database. See the database docs for the db’s API.

# schema.pluralizedModelClass

Return a registered model class. For example, given the file

// mirage/models/blog-post.js
import { Model } from 'ember-cli-mirage';

export default Model;

you could invoke this model’s class methods using schema.blogPosts:

this.get('/blog-posts', (schema) => {
  return schema.blogPosts.all();
});

Use ES6 destructuring to add some sugar:

this.get('/blog-posts', ({ blogPosts }) => {
  return blogPosts.all();
});

See the model docs for all available class methods.