Strapi 4,与关系字段的数据
我正在尝试创建一个新的event
(我的内容类型名称)陷入strapi rest api。
我的有效载荷:
{
title: "Event1",
description: "Somedescription",
date: "SomeDate",
store: 3 //this is the relation id
},
根据文档应该正确...创建事件,但关系尚未填补,它显示为空...
我的活动模式:
....
"store": {
"type": "relation",
"relation": "manyToOne",
"target": "api::store.store",
"inversedBy": "events"
}
.....
我看了strapi日志,似乎没有要做任何事情来记录这种关系,因为SQL看起来像这样:
{
method: 'insert',
options: {},
timeout: false,
cancelOnTimeout: false,
bindings: [
2022-05-21T15:14:47.404Z,
2022-05-30T16:00:00.000Z,
'h',
2022-05-21T15:14:47.403Z,
'h',
2022-05-21T15:14:47.404Z
],
__knexQueryUid: 'ZimE1XysRQZdZzz07fOQt',
sql: 'insert into "events" ("created_at", "date", "description", "published_at", "title", "updated_at") values (?, ?, ?, ?, ?, ?) returning "id"',
returning: 'id'
}
知道我在做什么错吗?
I am trying to create a new event
(my content type name) trough the strapi rest API.
My payload:
{
title: "Event1",
description: "Somedescription",
date: "SomeDate",
store: 3 //this is the relation id
},
According to the documentation it should be correct... the event is created but the relation is not being filled, it shows as empty...
my events schema:
....
"store": {
"type": "relation",
"relation": "manyToOne",
"target": "api::store.store",
"inversedBy": "events"
}
.....
I took a look at the strapi log and it does not seem to be doing any try to record the relation because the sql looks like this:
{
method: 'insert',
options: {},
timeout: false,
cancelOnTimeout: false,
bindings: [
2022-05-21T15:14:47.404Z,
2022-05-30T16:00:00.000Z,
'h',
2022-05-21T15:14:47.403Z,
'h',
2022-05-21T15:14:47.404Z
],
__knexQueryUid: 'ZimE1XysRQZdZzz07fOQt',
sql: 'insert into "events" ("created_at", "date", "description", "published_at", "title", "updated_at") values (?, ?, ?, ?, ?, ?) returning "id"',
returning: 'id'
}
Any idea what I am doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论