Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/spreed.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib/Model
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2022-03-31 20:13:08 +0300
committerJoas Schilling <coding@schilljs.com>2022-03-31 20:18:58 +0300
commit7fe2cf5c54b2f9b4584d639ab66d89d36b28bc76 (patch)
tree87722a2c37e27dcc556433754460cc3c19cedae9 /lib/Model
parente9c6de6a94635bd249fdaa407120e6db4b9da865 (diff)
Handle deleting
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/Model')
-rw-r--r--lib/Model/AttachmentMapper.php20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/Model/AttachmentMapper.php b/lib/Model/AttachmentMapper.php
index 039d7c1c1..484239483 100644
--- a/lib/Model/AttachmentMapper.php
+++ b/lib/Model/AttachmentMapper.php
@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace OCA\Talk\Model;
use OCP\AppFramework\Db\QBMapper;
+use OCP\AppFramework\Db\TTransactional;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IDBConnection;
@@ -33,6 +34,7 @@ use OCP\IDBConnection;
* @method Attachment[] findEntities(IQueryBuilder $query)
*/
class AttachmentMapper extends QBMapper {
+ use TTransactional;
/**
* @param IDBConnection $db
@@ -76,4 +78,22 @@ class AttachmentMapper extends QBMapper {
return $this->findEntities($query);
}
+
+ public function deleteByMessageId(int $messageId): void {
+ $query = $this->db->getQueryBuilder();
+ $query->delete($this->getTableName())
+ ->where($query->expr()->eq('message_id', $query->createNamedParameter($messageId, IQueryBuilder::PARAM_INT)));
+
+ $query->executeStatement();
+ }
+
+ public function deleteByRoomId(int $roomId): void {
+ $query = $this->db->getQueryBuilder();
+ $query->delete($this->getTableName())
+ ->where($query->expr()->eq('room_id', $query->createNamedParameter($roomId, IQueryBuilder::PARAM_INT)));
+
+ $this->atomic(static function () use ($query) {
+ $query->executeStatement();
+ }, $this->db);
+ }
}