【问题标题】:Is it possible to hard delete a Directus item through the API or app?是否可以通过 API 或应用程序硬删除 Directus 项目?
【发布时间】:2021-07-05 18:04:27
【问题描述】:

通过 UI 或 API 从具有状态字段的集合中删除项目会导致项目被软删除。但是,在这一特定情况下,我们希望将其从数据库中完全删除。

如果不可能,是否可以通过从带有集合名称的表中删除它来安全地通过数据库完成?这样做有什么副作用吗?

【问题讨论】:

  • 项目是指唱片还是收藏?对于第二个问题,Directus 应该完全可以从数据库中删除。我建议还删除系统表中与该项目相关的记录(directus_collections/fields)
  • 一条记录。所以基本上这个docs.directus.io/reference/api/items/#delete-an-item,但实际上是通过将“已删除”字段设置为true来删除记录而不是软删除。
  • Directus 不会进行软删除。您是在自定义集合中定义数据库表的人。 Directus 不会在那里添加任何系统字段,因为它们的概念不会触及您的主要模式。所以不确定你的设置是什么导致软删除
  • 显然软删除行为是由状态字段 (v8.docs.directus.io/guides/status.html#soft-delete) 添加的。编辑了问题。
  • 啊,对不起。我以为是 V9 的,我的错。

标签: directus


【解决方案1】:

在本页找到答案https://v8.docs.directus.io/guides/status.html#soft-delete

When deleting an item, the API does the following:

Check if the collection has a status field
Check if the delta data has the status field (meaning the status was changed)
Check if the new status value (from delta data) has soft_delete = true
If yes, it sets the action to SOFT_DELETE
If no, it hard deletes the item (permanently removed from the database)

【讨论】:

    猜你喜欢
    • 2023-02-09
    • 2015-10-11
    • 2012-11-29
    • 1970-01-01
    • 2011-08-31
    • 1970-01-01
    • 1970-01-01
    • 2021-09-17
    • 1970-01-01
    相关资源
    最近更新 更多