如何在房间数据中链接删除

发布于 2025-01-28 18:39:03 字数 115 浏览 2 评论 0原文

我有两个数据库或两个表ex:一个用于比赛的数据库,一个用于聊天JN事件部分中,请注意,将所有消息插入一个表中,意味着每个匹配的每个聊天都插入了同一表中 我的目标是当我删除一组比赛时,我需要自动删除与这些聊天的所有聊天

I have two data base or two tables ex:one for matches and one for chat jn event section in match note that the all messages is inserted in one table mean that every chat of every match is inserted in the same table
My target is when I delete a group of matches I need to automatically delete all chats of those match with

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

初吻给了烟 2025-02-04 18:39:03

您可以

  • 使用后删除触发器,也
  • 可以将外键定义(以耗尽的操作)作为级联反应,或者以
  • 编程方式进行删除(也许是通过调用两个删除的单个函数(主要是父母,另一个是删除孩子的删除 。

) 如果不是exsits .... ),以便触发器已经存在,但忽略了创建)。

<代码>创建触发器( sqlite.org/lang_createtrigger.html“ rel =“ nofollow noreferrer”> https://sqlite.org/lang_createtrigger.html 有关触发器的更多信息。
对于外国钥匙,您可能希望参考 https://developer.android.com/reference /androidx/room/foreferkey

You could

  • use an AFTER DELETE TRIGGER, or
  • use a FOREIGN KEY definition with the onDelete action as CASCADE, or
  • do the deletion programmatically (perhaps via a single function that invokes both deletions (the primary being the parent, the other being deletion of the children).

Room doesn't support TRIGGERS via annotation so you would have to create the TRIGGER(s) via code, probably using a CallBack with either, or perhaps both the onCreate or onOpen methods/functions overridden (if in onOpen then you should use CREATE TRIGGER IF NOT EXSITS .... so that if the trigger already exists that it doesn't fail but ignores the creation).

You may wish to refer to https://sqlite.org/lang_createtrigger.html for more information regarding Triggers.
For Foreign Keys you may wish to refer to https://developer.android.com/reference/androidx/room/ForeignKey

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文