我找到了以下帮助信息。使用
ember help generate model
参考,https://github.com/ember-cli/ember-cli/pull/3316
Requested ember-cli commands:
ember generate <blueprint> <options...>
Generates new code from blueprints.
aliases: g
--dry-run (Boolean) (Default: false)
aliases: -d
--verbose (Boolean) (Default: false)
aliases: -v
--pod (Boolean) (Default: false)
aliases: -p
--classic (Boolean) (Default: false)
aliases: -c
--dummy (Boolean) (Default: false)
aliases: -dum, -id
--in-repo-addon (String) (Default: null)
aliases: --in-repo <value>, -ir <value>
model <name> <attr:type>
Generates an ember-data model.
You may generate models with as many attrs as you would like to pass. The following attribute types are supported:
<attr-name>
<attr-name>:array
<attr-name>:boolean
<attr-name>:date
<attr-name>:object
<attr-name>:number
<attr-name>:string
<attr-name>:your-custom-transform
<attr-name>:belongs-to:<model-name>
<attr-name>:has-many:<model-name>
For instance: `ember generate model taco filling:belongs-to:protein toppings:has-many:toppings name:string price:number misc`
would result in the following model:
import DS from 'ember-data';
export default DS.Model.extend({
filling: DS.belongsTo('protein'),
toppings: DS.hasMany('topping'),
name: DS.attr('string'),
price: DS.attr('number'),
misc: DS.attr()
});