Model
Defines the schema and behavior for a record type in EmberData.
Syntax
class X extends Model { @attr field; } Returns
Model — A record class registered with the store.
Examples
import Model, { attr, belongsTo, hasMany } from '@ember-data/model';
export default class PostModel extends Model {
@attr('string') title;
@attr('date') publishedAt;
@belongsTo('author', { async: true, inverse: 'posts' }) author;
@hasMany('comment', { async: false, inverse: 'post' }) comments;
}
Notes
Define one model per record type using @attr, @belongsTo, and @hasMany.
Always specify the `inverse` and `async` options explicitly in modern
EmberData to avoid ambiguity.