商店软件6为自定义实体创建DB条目



我正试图按照BundleExample&Storefinder,我一直在为我的实体创建相应的条目。我向管理员添加了一个模块,它有三个组件:列表、详细信息和创建路由到[供应商名称]。[插件名称].list/.detail/.create。

来自custom\plugins[pluginname]\src\Resources\administration\module[vendor name]-[plugin-name]\index.js

routes:{
list:{
component: '[vendor-name]-[plugin-name]-list',
path: 'list'
},
detail:{
component: '[vendor-name]-[plugin-name]-detail',
path: 'detail/:id',
meta:{
parentPath: '[vendor-name].[plugin-name].list'
}
},
create:{
component: '[vendor-name]-[plugin-name]-create',
path: 'create',
meta:{
parentPath: '[vendor-name].[plugin-name].list'
}
}

/当数据库中没有条目时,列表将按预期显示,这意味着只有智能条可见。/细节无法工作,因为还没有实体,所以没有id。/create应该通过生成一个实例

created(){
this.repository = this.repositoryFactory.create('[vendor-name]_[plugin-name]');
this.repository.create(this.context);
}

但什么也没发生。

我确信我在某个地方忽略了一个基本步骤,如果有任何关于如何让它真正生成条目的建议,我将不胜感激。如果进一步的代码将有助于澄清这个问题,我将很乐意提供它。

this.repository.create(this.context);行将在客户端创建自定义实体的实体对象。要保存该实体,您必须调用this.repository.save(entity, this.context);。然后,您应该能够在浏览器的开发控制台中看到发送到服务器的请求。

有关更多信息,请查看文档。

请记住,this.repository.create(this.context);创建了一个空的伪实体,因此您至少需要设置自定义实体的所有必需字段。

最新更新