我的海市setup楼设置有两个模型,像这样的工厂
mirage / models / user.js
import { Model, hasMany } from 'ember-cli-mirage';
export default Model.extend({
posts: hasMany()
});
mirage / models / post.js
import { Model, belongsTo } from 'ember-cli-mirage';
export default Model.extend({
user: belongsTo()
});
mirage / factory / user.js
import { Factory, faker } from 'ember-cli-mirage';
export default Factory.extend({
name(i) {
return `Person ${i}`;
},
afterCreate(user, server){
server.create('post', 10, { user });
}
});
mirage / factories / post.js
import { Factory, association } from 'ember-cli-mirage';
export default Factory.extend({
title(i) {
return `Show ${i}`;
},
description(){
return faker.lorem.paragraph();
},
user: association()
});
mirage / serializers / user.js
import { RestSerializer } from 'ember-cli-mirage';
export default RestSerializer.extend({
include: ['posts']
});
mirage / scenarios / default.js
export default function(server) {
server.createList('user', 10);
}
在模型挂钩中,我向this.get('store').findAll('user')
发出请求,然后在模板中对其进行循环。我的问题是,此get请求仅包括每个用户1个帖子。我本来希望每个用户创建10条帖子。
我在这里想念什么?