UNPKG

1.28 kBPlain TextView Raw
1/**
2 In EmberData a `Model` is a class defining the attributes and relationships
3 of a specific resource `type` (model name). In this sense it represents a static "schema".
4
5 Data for individual resources fetched from your API is presented
6 to the UI via instances of the `Model`s you define.
7
8 An instantiated `Model` is referred to as a `record`.
9
10 When we refer to the `ModelClass` we are referring to the class definition
11 and the static schema methods present on it.
12
13 When we refer to a `record` we refer to a specific class instance presenting
14 the resource data for a given `type` and `id`.
15
16 ### Defining a Model
17
18 ```app/models/person.js
19 import Model, { attr, belongsTo, hasMany } from '@ember-data/model';
20
21 export default Model.extend({
22 name: attr(),
23
24 dog: belongsTo('pet', { inverse: 'owners', async: false }),
25
26 friends: hasMany('person', { inverse: 'friends', async: true }),
27 });
28 ```
29
30 ### modelName convention
31
32 By convention, the name of a given model (its `type`) matches the name
33 of the file in the `app/models` folder and should be lowercase, singular
34 and dasherized.
35
36 @module @ember-data/model
37 @main @ember-data/model
38 @class Model
39 @public
40 */
41
42export { Model as default, attr, belongsTo, hasMany } from './-private';