Strapi 4,与关系字段的数据

发布于 2025-01-31 01:04:00 字数 1025 浏览 1 评论 0原文

我正在尝试创建一个新的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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文